4

From the view of the folder tree on the left we see that the .c files are in a directory under workspace named pset1. At the bottom we see that the compile is being run from the workspace directory. You need to cd pset1 before running the make command.


3

Hmmm... I don't see a main() declaration anywhere. [Edit] The problem in this question is probably the most fundamental part of learning to write a C program. You need to be able to understand how a C program is structured. In comments that have been deleted, the problem persists. This is so basic an issue that if you can't resolve it, you really need to ...


2

Your code may be the same as David's but your environment is (drastically) different. You will possibly (probably?) have to make adjustments to all the courseware as you go along. In the IDE50 environment (ubuntu), if you want to compile a local .h file, you would include it with #include "cs50.h", using double-quotes instead of <>. And you'll need a ...


2

for (int i = 0; i < candidate_count; i++) { if (candidates[i].votes >= maxvote) { maxvote = candidates[i].votes; winner = candidates[i].name; printf("The winner is %s\n", winner); } } the logic of your code to get the max number of votes is correct, but your logic to get the winner is a ...


1

when casting data types, the cast keyword, in this case float, needs to be enclosed in parentheses. if( (float)...) If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


1

#include <cs50.h> #include <math.h> int main(void) { int n = 0; do { n = (get_float("Change owed: ") * 100); } while (n < 0); int q = ((n / 25) % 10); //<- need semicolon to terminate each statement int d = ((q / 10) % 10); int r = ((d / 5) % 10); int c = (n % 10); int i = q + d + n + c; printf("%i", i); // <- ...


1

Can't see your code, but the spec says: You should not modify anything else in tideman.c other than the implementations of the vote, record_preferences, add_pairs, sort_pairs, lock_pairs, and print_winner functions (and the inclusion of additional header files, if you’d like). You are permitted to add additional functions to tideman.c, so long as you do ...


1

The compiler command is make test (unless you want to supply all the switches for clang). Notice that make echos to the terminal the actual clang command it uses.


1

Your code is incrementing maxvote every time your if statement is true.. The goal is to get the max number of votes and see then check if who are the candidates that have the same number of votes to the max votes you got. int maxvote = 0; for (int i = 0; i < candidate_count; i++) { if (candidates[i].votes > 0) { ...


1

The function signature has changed. From the CS50 Programmer's Manual char *get_string (const char *format, ...); DESCRIPTION Prompts user for a line of text from standard input and returns it as a string (char *), sans trailing line ending. Supports CR (\r), LF (\n), and CRLF (\r\n) as line endings. Stores string on heap, but library’s ...


1

The fifteen.c file was distributed in the pset and was not supposed to be altered in any way. The only file that should be changed is helpers.c. Did you alter fifteen.c? Clearly, yes. That explains the error message. It isn't saying that your program executes and returns 1 or 0, it says that it didn't compile, so the compiler returned 1. The compile failed ...


1

helpers.c does not contain a main function, so it cannot be compiled into an executable. Its code is used in find.c, make find instead of helpers, using either make find or clang -ggdb3 -O0 -std=c99 -Wall -Werror -o find find.c helpers.c -lcs50 -lm and use calls to find to debug helpers.c.


1

struct node* children[27] = {}; This is an error because this is part of a typedef. You can't assign values or initialize in a typedef. A typedef is not a variable, so it cannot be initialized. Once you create an actual var of that type, the var can then be initialized. Any initializations that are more than a constant, i.e., a calculation or allocation of ...


1

It looks as though you don't have a full understanding of how directory structure works. Looking at the image that you posted, you have already created the subdirectory pset1 in the directory ~/workspace. If you look at the command line prompt, it says clairefasstner:~/workspace/pset1. That prompt gives the username before the colon and everything after the ...


1

It's what you are comparing that is giving you issues. You are comparing an array element to the array itself, values[x] > values. Or, to put it another way, you have the same typo (or a cut and paste error) in three different places. Try using value instead of values as specified in the function signature bool search(int value, int values[], int n) ...


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