5

The make utility actually calls the clang compiler with special options that can be set for a project. When I run make in the ide it actually runs the following: clang -fsanitize=integer -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow temp.c -lcrypt -lcs50 -lm -o temp Most of that is unimportant to understand ...


5

From the What's new? in CS50 2017 document: CS50 Library To be more consistent with stylistic conventions in C, we’ve renamed the functions in the CS50 Library as follows: GetChar is now get_char GetFloat is now get_float GetInt is now get_int GetLongLong is now get_long_long GetString is now get_string The old spellings still work (for now!) but best to ...


2

Your problem is that you don't use printf() correctly. Here is what you have: printf("Hello, %s\n"); The %s part, tells printf() that in that spot is going to be a string variable, it's not the name of your variable. If you wanted to print an int in that spot you would use the %d specification. So this is how you should use printf() (I will change the ...


2

If you know in advance how big of a string you are willing to accept, you can put the limit into your scanf argument itself. Try this small program: #include <stdio.h> int main(void) { char words[15]; scanf("%14s", words); printf("%s\n", words); } You're telling scanf to only take in 14 characters (with the 15th reserved for the null ...


1

Your get_string() has no arguments, while in the lectures we've been taught to always insert a prompt (in the form of a string) in between the parentheses. Try combining these two lines: printf("plaintext: "); char* plaintext = get_string(); into this one liner: char* plaintext = get_string("plaintext: ");


1

Solved! I ran "update50" in the terminal twice, and after the second time a prompt came up that told me I'm currently running "pip 9.0.1" and there is an update available for "pip 10.0.1", and told me what command to type for the update. After I entered the command, I waited about 20 seconds, made sure my code was correct and typed make int again - this ...


1

Your line numbers in code and in the error messages don't match, are off by one, so I'd guess you forgot to save, or compiled something else (another file, maybe of the same name in a different directory). A successful make run might print the command used to call the compiler, but the compiler itself will probably not print anything, just create a int file ...


1

Yes it's true that for simplicity's sake, in the first psets, we din't free() the strings allocated by GetString() and that caused memory leaks. Nevertheless, most modern operating systems can see when a program exists with memory leaks, and frees the memory itself. So even if you run your program a million times you would not notice any memory shortage (...


1

ROOT CAUSE: changes to the environment in update50. (Specifically CFLAGS, which changes -std=c11 to -std=gnu11). This affects all the cs50.h get_ functions. It is important to close any and all terminals to ensure the environment is refreshed. Or you can restart your workspace with CS50 IDE -> Restart. Let the chaos begin! As the CS50 team at Harvard ...


1

the isspace function should return a boolean, whereas you assign a char to the 'return value' of isspace. What you probably want to do is to check if, for every i, the current name[i] is a space, and then store name[i+1] (probably the initial) in some string or char for the initials. y++ takes the value of y and adds one. Because y is a char, thus an ascii ...


1

Be sure to save before making your program!


1

You can ask user to separate names with comma or space or some other delimiter. You can find strchr() function useful for parsing names in such an input. Another option is to ask further names in a loop by saying press y(or some character) to add another name.


1

Funny thing is that I can't get much to work right in cs50.h so I've just been looking up standard c programming techniques. It's just been much easier to find working examples on the Internet using standard c without cs50.h. for the life of me I can't get get_string() in cs50.h working even though I copied the example in the manual. This link has 3 great ...


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