Skip to main content
4 votes
Accepted

Pset3 Linear Search (control may reach end of non-void function)

The error message you're getting means the compiler isn't sure if the function will ever end (i.e. that there will be a return value under every possible eventuality). The problem lies in the first "...
ronga's user avatar
  • 1,415
3 votes
Accepted

Please help debug linear search program in C

Actually, as written, it does print the largest number, but only from sheer coincidence. The largest number in the array is 6, which is also the first number. Since the loop only runs once, it's ...
Cliff B's user avatar
  • 69.2k
1 vote
Accepted

Caesar: Validating the key - stuck

argv[] is a list of arguments introduced from the comand line. If you want to itterate through ever char in a particular argument you can do it by: argv[x][i] where x is the argument number and 'i' ...
Tritum's user avatar
  • 1,571
1 vote
Accepted

Linear find function always finding needle in hay stack and generating multiple numbers

You may not be doing anything wrong. As I recall (it's been more than a year), when you run the program (manually or with input from generate), it will always print out a prompt for "haystack[i]= ". ...
Cliff B's user avatar
  • 69.2k
1 vote
Accepted

How to create an input for the search function?

Your "small" program is a little complex, you can try the one I coded, based on your code to see if it serves you. The program accepts the entry of the number you want to search for the command line. ...
MARS's user avatar
  • 5,179
1 vote
Accepted

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

This error means that there was no main() in the source files. By doing make helpers it tried to compile the program using the default rule of building an executable based on the name given - helpers....
Cliff B's user avatar
  • 69.2k
1 vote
Accepted

Why am I generating the following errors with this code if it says it's compiled correctly?

One of the lessons of this pset is how to build an executable from multiple source files using a makefile. The link error is happening because you are trying to make helpers. Because there are no ...
Cliff B's user avatar
  • 69.2k
1 vote

Pset3 Linear Search (control may reach end of non-void function)

there's certainly a problem...two actually... first of all, why is your first condition including 0 as a possibility? surely there can't be a list of 0 members. secondly, you do not give your for ...
karuhanga's user avatar
  • 181
1 vote

pset3 linear search not working

That code will only test the first element in the list. If the first element is not the target, it will return false. Instead, if the first, or any element in the list is not the target, it should do ...
Cliff B's user avatar
  • 69.2k
1 vote

Cannot find the needle 127 in the haystack of 1000 random numbers using linear search . Any ideas on what I may have done wrong?

Asked and answered in comments. Except for a minor flaw, the search code appears correct. It should be finding 127. More likely, there's a problem with the code that loads the numbers in the array. ...
Cliff B's user avatar
  • 69.2k

Only top scored, non community-wiki answers of a minimum length are eligible