Hot answers tagged

2

-Wall means to enable all compiler warnings. And -Werror means treat all warnings as errors. In other words, any possible warning that the compiler has determined will be shown to you if your code meets it, and it will be treated as a compile error that must be fixed.


2

You have a series of issues here, all to do with correct program structure. Some of them are hiding others. First, int main (void); has a semicolon. This is causing problems and masking others. main should be structured like this: // includes go here #include.... // followed by main int main(void) { //main's code goes here, including variable ...


2

Your code passes the tests of cs50/2019/x/hello for me, so you probably did something wrong with the submission itself. A few things to check. Is this code saved as hello.c? Hello.c would be a different file. Is this code saved in the current directory? Likely not as much an issue in the lab environment. For example, if you type cat hello.c in the terminal, ...


1

This is a scope problem, the variable "change" declared in main is visible in the whole main program, but when declaring change in the DO-WHILE loop, this second variable is different from the first change that is shaded by this second. The reason is the rules of scope of a variable, you must have these clear rules, in general the variables ...


1

I fixed it for you. #include <cs50.h> int main(void) { //Prompt for the height of the pyramid int height; do { //Takes input, assigns it to height and prints it height = get_int("Pick a positive integer between 1 and 8:"); printf("Height: %d\n", height); } while (height<1 || height>8)...


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

Yes: ~/workspace/Pset1/ $ cat hello.c #include <cs50.h> #include <stdio.h> int main(void) { //ask for name string name = get_string("What is your name?\n"); // print hello, name printf("hello, %s\n", name); } ~/workspace/Pset1/ $ When I do check50 hello I get the following error: Preparing............ Uploading........... ...


1

No. When clang sees a commented line, it just skips it. So no, comments are not included in the executable file. If this answers your question please accept it by clicking the gray check-mark to the left, so that it becomes green. You can also vote it up by pressing the up arrow above the check-mark. And don't forget to keep coding!


1

Where did your Makefile go? Create a text file called Makefile in your pset5 directory, and paste this default code into it: # # Makefile # # Computer Science 50 # Problem Set 5 # # compiler to use CC = clang # flags to pass compiler CFLAGS = -ggdb -O0 -Qunused-arguments -std=c99 -Wall -Werror # name for executable EXE = speller # space-separated list ...


1

are you trying make greedy.c ? if yes, try this; make greedy


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