Skip to main content

Questions tagged [helpers]

Filter by
Sorted by
Tagged with
2 votes
3 answers
4k views

helpers.c Doesn't Compile

I'm trying to compile helpers.c (pset 3), but it doesn't compile successfully. It gives me the following error: jharvard@appliance (~/Dropbox/pset3/find): make helpers clang -ggdb3 -O0 -std=c99 -Wall ...
user1289's user avatar
2 votes
1 answer
3k views

Selection sort seems right, but the values are not sorted

I have been running gdb on this, and it's true, the values are not sorted. But my logic seems fine. This is the selection sort, anyone know what I am missing? int min, hold, i, j; for (i = 1; i &...
Azurespot's user avatar
  • 203
2 votes
1 answer
844 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 ...
Tenacity's user avatar
  • 157
2 votes
2 answers
401 views

why can't I compile the program that I wrote to test helpers.c?

I've made a program to test my sort function. The only problem is that when I try to compile it gives me the "undefined reference to 'sort'" error as seen in the below: For context, I have taken the ...
Brian Poindexter's user avatar
2 votes
1 answer
2k views

Pset 3: undefined reference to sort error with exit code 1

Here is the error code. Tried Make All. Tried several different sort & search algorithms and coding. clang -ggdb3 -O0 -std=c99 -Wall -Werror -o find find.c helpers.c -lcs50 -lm /tmp/find-3c23ac....
SparMar's user avatar
  • 21
2 votes
1 answer
1k views

How does find.c know to use functions from helpers.c?

I've been beating my head trying to understand the second assignment for pset 3. It states in part: Notice that find.c calls search, a function declared in helpers.h. Unfortunately, we forgot to ...
Chess Dad's user avatar
1 vote
2 answers
260 views

Mess of Error Messages From Clang

I just started pset3 and when I try to compile my helpers function I get this crazy mess of error messages from clang. This is my code /** * helpers.c * * Computer ...
CameronBurkholder's user avatar
1 vote
1 answer
864 views

How to test helpers.c

I'm just wondering the best way to test out sort and search in helpers.c. Since the file won't compile/run on its own, how can I test the code that I'm writing?
dottified's user avatar
1 vote
2 answers
104 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 ...
Jason_V's user avatar
  • 182
1 vote
1 answer
423 views

pset3 find/helpers check50 error

When I run find, it reports that it finds the value when it's in the haystack, and reports that it didn't find it when it isn't. (i.e. it works according to the specification). make find works with ...
Avishai Fuss 's user avatar
1 vote
1 answer
215 views

Segmentation fault core dump with find and helpers.c

I have been working on find.c for the last three days, without success. When I run check50, 50% of the time it compiles helpers.c but then does not find 42 as it is supposed to. The other 50% of the ...
Dalia Platt's user avatar
1 vote
1 answer
7k views

What does "error in backend: IO failure on output stream" signify?

I altered the code in helpers.c in such a way that when the difference between the find value and the "haystack" value equals zero the program returns true. However find will no longer compile and ...
Adam Wilson's user avatar
1 vote
1 answer
42 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[...
IerNL's user avatar
  • 11
0 votes
1 answer
3k views

pset3 search and sort

First, thank you for your time. I am working on pset3. I don't know why my code does not work. I also have some questions: 1. Do I need a main function? I mean, do i need main to call the functions? ...
abc2015's user avatar
  • 15
0 votes
1 answer
508 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 ...
IMH's user avatar
  • 3
0 votes
1 answer
319 views

Pset3: Helpers.c Binary Search Fails on checks that have 42 entered last

For some reason my implementation of binary search for Pset3 fails to work correctly whenever the last number added to the "haystack" is 42. During use of GDB, I found that this is due to the part of ...
OddballGreg's user avatar
0 votes
1 answer
585 views

Pset3 Search/Find problems

I have no idea what the problems are with this code, so any help would be appreciated. The code compiles, but the output is skewed. It only sorts after a certain amount of characters, and then sorts ...
mmoore's user avatar
  • 57
0 votes
1 answer
259 views

relocation error in helper.c

This is my code bool search(int value, int values[], int n) { // TODO: implement a searching algorithm for (int i = 0; i < n; i++) { if(values[i] == value) { ...
HMiddleton's user avatar
0 votes
2 answers
3k views

Pset 3 - Find and Helper.C

Question about find and helpers.c. When I run check50 on my code, I get the following error below: :( doesn't find 42 in {39,40,41} \ expected an exit code of 1, not 0 :( doesn't find 42 in {39,...
Jen Choi's user avatar
0 votes
1 answer
78 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; } ...
Vaish MK's user avatar
  • 167
0 votes
2 answers
73 views

find.c compiles but fails check50 - I believe binary search is to blame

Why does my code fail check50? This is the code of my binary search. I know it's buggy, and I spent the last hours reading answers to similar questions, the information I found doesn't quite cut it ...
Iury Sikorsky's user avatar
0 votes
1 answer
102 views

CS50x helpers.c help with looping

void sort(int values[], int n) { int temp; int swapcounter = 1; while (swapcounter != 0) { for(int i = 0; i < n; i++) { swapcounter = 0; ...
Timmy Tran's user avatar
0 votes
1 answer
201 views

"Control may reach end of non-void function" but I'm sure my else statements take care of it? [duplicate]

I know this has been asked many times before, but I looked through all the questions and still don't get it. I know what the error means, I'm just convinced that my code ensures that whatever happens,...
mathmagician's user avatar
0 votes
1 answer
2k views

How to fix the "expected identifier or '('" error?

I've been stuck at this for a long time. How can I fix this error?
Matthew's user avatar
0 votes
1 answer
2k views

"Expected an exit code of 0"

I get the following error when I check50 helpers.c: \ expected an exit code of 0, not standard error of "helpers.c:24:17: error: implicit declar..." Here is the source code of helpers.c: bool search(...
user103853's user avatar
0 votes
1 answer
83 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 ...
Babalola Rotimi's user avatar
0 votes
1 answer
147 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 ...
Kam Clark's user avatar
0 votes
1 answer
49 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 ...
d-mick's user avatar
  • 3
0 votes
1 answer
72 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 ...
Chris's user avatar
  • 19
0 votes
1 answer
170 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 ...
aman0016's user avatar
0 votes
1 answer
94 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 :) ...
Richard Le's user avatar
0 votes
1 answer
80 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 %...
Guillaume_slize's user avatar
0 votes
1 answer
10k 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 ...
Nova's user avatar
  • 7
0 votes
1 answer
68 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 ...
Justin's user avatar
  • 5
0 votes
1 answer
30 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("%...
Yousif Alnajjar's user avatar
0 votes
2 answers
101 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 : ~/...
sp3's user avatar
  • 3
0 votes
1 answer
136 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 ...
adam kirsch's user avatar
0 votes
1 answer
1k 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 ...
Tod Lazarov's user avatar
0 votes
1 answer
56 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; ...
gondu riya's user avatar
0 votes
1 answer
65 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 ...
Andrew's user avatar
  • 21
0 votes
1 answer
75 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 ...
Kgotso Koete's user avatar
0 votes
2 answers
361 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 ...
Flesheaters's user avatar
0 votes
1 answer
51 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 ...
Samir-B's user avatar
  • 11
0 votes
1 answer
81 views

Pset3 recursive binary search function - check50 gives me four :( and I don't know why

I would be really grateful if someone could offer me a hint as to where I'm going wrong with this - I've been stuck for a couple of days now. When I work through the code step by step on paper it ...
J M COOPER's user avatar
0 votes
1 answer
611 views

Pset 3 helper.c issue

I have thiscode: /** * helpers.c * * Computer Science 50 * Problem Set 3 * * Helper functions for Problem Set 3. */ #include <cs50.h> #include "helpers.h" /** * Returns true if value ...
Vincent Tang's user avatar
0 votes
1 answer
70 views

Pset3 Problem with binary search

The code below fails to pass the last input of check50, namely {39,40,41,43} and I know it isn't a bug in the code itself, after hours of tinkering and rewriting it I'm pretty sure this code works ...
Petar Petrov's user avatar
0 votes
1 answer
105 views

Check50 is claiming that it's recieving an exit code of 0 rather than 1 (different scenario)

I know this question has been answered before (pset 3 "search": expected an exit code of 0, not 1), but I took a look at it, and it seems that the scenario in which the person asked the ...
jayfeather31's user avatar
0 votes
1 answer
100 views

"make all" for linear search when changing helpers.c results in "error: control may reach end of non-void function"

Here's the problem. After adding to helpers.c a linear search that will return true if the value is found (per the pset3 spec), I "make all" in the terminal to update helpers.c before testing it, but ...
MEK's user avatar
  • 7
0 votes
1 answer
90 views

Iterative binary search only returns false (may be because of sort)

I've just looked at every similar question in this forum and couldn't find one that helped me, so I'm posting my own. I've tried everything (except GDB because I don't quite understand find without ...
Talita Maria Briganti Barbosa's user avatar
0 votes
1 answer
54 views

Find.c won't quit

I have just implemented binary search on helpers.c and it compiles perfectly, but, when I try to execute find, the program doesn't quit. I tried with ./generate 3 2 | ./find 59797 (because 59797 is ...
Talita Maria Briganti Barbosa's user avatar