Questions tagged [helpers]
The helpers tag has no usage guidance.
111 questions
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 ...
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 &...
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 ...
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 ...
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....
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 ...
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 ...
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?
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 ...
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 ...
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 ...
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 ...
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[...
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?
...
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 ...
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 ...
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 ...
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)
{
...
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,...
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;
}
...
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 ...
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;
...
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,...
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?
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(...
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 ...
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 ...
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 ...
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 ...
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 ...
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
:) ...
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 %...
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 ...
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 ...
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("%...
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 :
~/...
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 ...
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 ...
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;
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...