Questions tagged [helpers]

The tag has no usage guidance.

1
vote
1answer
21 views

It says: helpers.c compiles expected exit code 0, not 1 (I really don't get it)

#include <cs50.h> #include <math.h> #include <string.h> #include <stdlib.h> int duration(string fraction) { int x = atoi(&fraction[0]); int y = atoi(&fraction[...
0
votes
2answers
25 views

Pset3, Issue with duration in helpers. Can't compile, strange error message

Back again, this time trying to figure out pset3. I think everone is familiar with the pset, but for anyone who isn't, I'm trying to convert a fraction (1/8, 1/4, 1/2, etc) to a number of eighths. ...
0
votes
1answer
53 views

PSET3: Music, getting this error 'expected exit code 0, not 1'

Please I'm getting this error when I try to submit pset3. expected exit code 0, not 1 My code for synthesizing works fine and I'm able to play wav files from text files. I'm not sure if it's ok ...
0
votes
1answer
75 views

PSET 3 Music doesn't give correct frequencies

After I finished up to problem set 4, I went back to submit my old Psets, but to my surprise many of the had errors, this being one of them. My code compiles fine, but doesn't give the correct ...
0
votes
1answer
49 views

Pset3 Helpers.c “timing out while waiting for program to exit”

I have been working on Helpers.c for an extremely long time now, and I have little help with the style of the program due to my doing this totally on my own. When I run check50 from the 2018 pset3 doc,...
0
votes
1answer
474 views

Problem with pow() function, int frequency, helpers.c, pset3, music

I'm not getting the correct frequencies. When I execute ./notes, C4 through G#4 all return 220, and A4 through B4 return 440. I've determined that the problem must be with pow(), I just don't know ...
0
votes
1answer
60 views

PSET3 - Find (More) - Debugging and bubble sort issues

Pset 3 (2017): create program, find, that finds a number in an array of generated numbers. We need to implement functions for both sorting and searching the array using helper files. Since a binary ...
2
votes
1answer
829 views

Pset3 Helpers.c Frequency Not Working

Right now I am working on Pset3 with Music. I'm focusing on getting the frequency (in Hz) of all the octaves of A. I am including accidentals in my work as well. The problem is that A4 returns 449 ...
0
votes
1answer
28 views

pset3 keeps returning 1 even when it should return 0

bool search(int value, int values[], int n) { // TODO: implement a searching algorithm if (value < 0) return false; int s = 0; int e = n - 1; int m = ((s + e) / 2); while (s <= e) { ...
0
votes
1answer
102 views

week 3 find problem

I thought I finally made the program find work, but it still won't function when I test it with help50. I have looked at the code the whole day and just cannot seem to figure out what to do to solve ...
0
votes
1answer
47 views

Any help is appreciated with pset3 check 50

Any advice on how to solve this problem? My code finds some numbers but not others and times out at the end of the check 50 check. Below is my code for helpers.c /** * helpers.c * * Helper ...
0
votes
1answer
49 views

find is not compiling

/** * helpers.c * * Helper functions for Problem Set 3. */ #include <cs50.h> #include<stdio.h> #include "helpers.h" /** * Returns true if value is in array of ...
0
votes
1answer
111 views

Pset 3 helpers.c check 50 errors

#include <cs50.h> #include <stdio.h> #include "helpers.h" //TODO binearysearch, om te controlere van de waarde. bool search(int value, int values[], int n) { int left = 0; int ...
0
votes
1answer
142 views

How to debug find.c?

I'm just working on find.c and helpers.c. My sort is not completely working yet and I'm trying to debug the program but the debugger is not working. Is there anything special I have to do since find....
0
votes
1answer
66 views

pset3: sort and search work in separate files, but my helpers.c doesn't work

I dealt with sorting in a separate file first, and then I dealt with searching in another file. They seem to work okay or at least worked for the numbers I feed in, but when I put them in helpers and ...
0
votes
1answer
156 views

pset3 find- check50 Why doesn't find returns frowning face

I am not sure where I have gone wrong with helpers.c. I passed all check50 tests except for 2 under "doesn't find". My code is below: code removed What check50 returns is as follow: :) helpers.c ...
0
votes
1answer
74 views

PSet 3: binary search help

My program is almost working, I just cannot figure out why my binary search is not working. I am pretty sure that the sorting is fine. Any help would be appreciated. check50: :) helpers.c exists :) ...
0
votes
1answer
73 views

Puzzled by Pset3 - find less confortable- sorting output

I just checked my code for Pset3 finds less confortable and it works but I am puzzled by some of the printf I put to debug my code. I put this just at the end of my sorting function: printf("%i %...
0
votes
1answer
2k views

'int' but the argument has type 'int * problem with sort in helpers.c

I am having a problem with returning the sorted value in the function sorted. I know it has something too do with fun pointers. On a side note, how is a function suppost return something if it's ...
0
votes
1answer
73 views

pset3 find, failing half the checks!

so currently doing pset3 & i think my sort function is all good (i've printf'd each value & it's all in the right order), but when trying to implement binary search it's failing half the tests ...
0
votes
1answer
64 views

Helpers.c binary search help

Somehow I am messing this up, I just can't figure out why. Sort works perfectly, as does my linear search function and they can pass Check50. However my implementation of binary search hasn't worked ...
0
votes
1answer
78 views

PSET3 helpers.c

:( finds 42 in {42,40,39,41} \ expected an exit code of 0, not 1 What can I make out of this error message. Here's my code for binary search,selection sort:
0
votes
1answer
74 views

PSET3 helpers.c Please help!

Please help me find what's wrong with my code. For academic honesty I am just sharing the output right now but can provide if needed and the algorithm for binary search and selection sort which are as ...
0
votes
0answers
83 views

pset3 why did this cause a segmentation error but only sometimes with same input?

So I was running into an issue with my counting sort algorithm throwing segmentation errors sometimes. The offending code: while (count < n) { while (counting_array[j] > 0) { ...
0
votes
1answer
27 views

How to fix z++ in for loop not increasing the value of z?

I have the following code: for (int x = 0, w = 50; x <= w; x++) { if (count[x] > 0) { for (int y = count[x], z = 0; z < y; z++) { values[z] = x; eprintf("%...
1
vote
2answers
102 views

Binary Search Pset 3 help

As my question is titled, I would appreciate help with my binary search, shown below. Currently, the search will always return false. I am almost certain that my sorting algorithm is correct, as it ...
0
votes
1answer
120 views

Segmentation fault on pset3 (find : more comfortable)

My program got a problem when I used this command './generate 1000 50 | ./find 127' which generating random number to run it. It shows "Segmentation fault", but it works fine when I type the input ...
0
votes
2answers
89 views

pset3 - find Why do we need a limit at 65535 to pass check50?

While debugging locally, the program executes as expected, tested with random inputs and the check50 proposed inputs. When uploading by using check50, it returns the following, never finding 42 : ~/...
0
votes
1answer
110 views

helpers.c still returning the wrong exit code?

When I check my code for helpers.c using check50, it appears that the code is technically working, ie it finds values in the array, and doesn't find them if there not. However, when it finds a number ...
0
votes
1answer
211 views

Assigning an empty array with malloc has a random number in it

Im trying to debug why my helpers.c in the find pset is not working perfectly. I kept getting random large numbers in my array and I kept going up the ladder in the function to the point of ...
0
votes
0answers
47 views

Result doesn't match expected output

I just finished the helpers.c pset, where you have to implement a counting sort and then a binary search. I havent made it recursive yet but it works in all of my own test cases. I also ran the ./...
0
votes
1answer
16 views

logic fail with selection search (and nested for loops in general?)

I hate having to ask this q, but I have to know. In my outer for loop, I made the condition i < n - 1 because arrays are 0 indexed and therefore always one less than the size of the array. I don'...
0
votes
1answer
559 views

pset3: expected an exit code of 0, not 1

I'm getting this error in some of my checks. Here's my code: bool search(int value, int values[], int n){ int mid, left, right; left = 0; right = n - 1; while (left != right){ mid = (right + ...
0
votes
1answer
483 views

pset3 find more comfortable

i had written the C code for sort and search it is not working yet my code for helper.c is /** * helpers.c * * Helper functions for Problem Set 3. */ #include <cs50.h> #include "helpers.h"...
0
votes
1answer
69 views

pset3 making helpers.c gives 50 lines of errors (doesn't compile)

I successfully finished my helpers.c file fixing whatever mistake was pointed out by "make" but now running "make helpers" gives approximately 50 lines of error from the debug log of the gnu compiler. ...
0
votes
1answer
485 views

CS50 Problem Set 3 Helpers.c PROBLEMS

I have been trying to solve Pset3 search and sort - looked at all possible online forums but I cannot solve it. Please help. Where am I going wrong? Is my binary search OK? What about my bubble sort? ...
0
votes
1answer
113 views

CS50 pset3 helpers.c binary search() func problem

It seems that I have problem with recursive function call, I am not sure how to make it work, testing with ./generate 1000 50 | ./find 127 gives me segmentation fault. I believe the problem is within ...
0
votes
1answer
122 views

Pset3 helpers check50 errors how do I resolve

My search code: int low = 0; int high = n-1; int mid = (high + low) / 2; // while there are searchable elements while (low <= high) { { // if middle of values is equal to value, return ...
0
votes
1answer
707 views

Pset3 Find, I am so confused and need some direction please

I am going round and round in circles with this pset, please can someone give me some direction, below is a copy of my code: /** * helpers.c * * Helper functions for Problem Set 3. */ #include &...
0
votes
1answer
54 views

pset3 buble sort() function works but it gives wrong output in helper.c

this is my bubble sort program which works fine: #include <stdio.h> #include <stdbool.h> /** * Sorts array of n values. */ void sort(int values[], int n) { bool no_swap = false; ...
0
votes
1answer
49 views

WHAT is wrong with this small bool snippet? PSET3. It always returns true. Even if the needle is not in the haystack

bool search(int value, int values[], int n) { int p; if(n<=0) { return 1; } for(p=0;p==n;p++) { if(values[p]==value) { return 0; break; } ...
0
votes
1answer
73 views

help with helpers.c

The following is my my helpers.c code and whenever i enter it my code gets killed by the check50 server. I have tried changing my code a several times but O am getting the same result. What should i ...
0
votes
1answer
160 views

pset3: selection sort code not compiling

I'm a beginner and I've been working on the code for selection sort. The code seems right: But whenever I try to compile helpers.c I keep getting this error and I can't move forward: Could anyone ...
0
votes
1answer
35 views

Pset3: Program does not break out of loop when needle is not found. Not sure what's wrong

#include <cs50.h> #include "helpers.h" bool search(int value, int values[], int n) { int min = 0; int max = n - 1; int midpoint = (max + min) / 2; while (n > 0) { if (values[midpoint] =...
0
votes
1answer
63 views

pset3 helpers.c ERROR

so i tried to make my helpers.c to check if i wrote code correctly it worked for 3 times i removed mistakes one by one but then when i tried include stdio.h to make printf("found it!"); function to ...
0
votes
1answer
92 views

pset3 binary search , problems with check50

i have tried a lot but cannot find the meaning of the last two errors of check50 please help
0
votes
1answer
83 views

CS50 Helpers.c Binary Search: Fails Last Check50

I've written my code for helpers.c - the binary search and bubble sort - but my code fails the last testing of check50. It's killed by the server. Is something wrong with my code, server, or appliance?...
0
votes
1answer
63 views

Pset 3 Helper: Linear search function implem/ header file won't compile

I just tried to compile this file(helpers.c), as a function implementation that is already included as a header for the main programme(find.c). I am not sure what else to do anymore, I have tried ...
0
votes
2answers
335 views

How do I test sort function in helpers.c pset3?

I am having trouble testing my bubble sort algorithm. I have used gdb but the output from gdb isn't telling me anything I understand at this point (even after reading several tutorials, etc.) Find.c ...
0
votes
1answer
45 views

linearsearch in helpers.c pset3

/** * helpers.c * * Computer Science 50 * Problem Set 3 * * Helper functions for Problem Set 3. */ #include <cs50.h> #include "helpers.h" /** * Returns true if value is in array of n ...