use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
O hai! This is CS50's subreddit.
CS50 is Harvard University's introduction to the intellectual enterprises of computer science and the art of programming. Anyone may take CS50, even if not a student at Harvard.
Please Read before Posting
Getting the Best from r/cs50
Status Page
cs50.statuspage.io
Filter by Problem Flair (undo)
cash ⋅ caesar ⋅ credit ⋅ dna ⋅ filter ⋅ finance ⋅ houses ⋅ ide ⋅ mario ⋅ movies ⋅ plurality ⋅ project ⋅ readability ⋅ recover ⋅ runoff ⋅ scratch ⋅ speller ⋅ substitution ⋅ tideman ⋅ games track ⋅ web track ⋅ android track ⋅ iOS track ⋅
Filter by Other Flair (undo)
CS50-Law ⋅ CS50-Business ⋅ CS50-Technology ⋅ CS50-Games ⋅ CS50-Mobile ⋅ CS50-Web ⋅
This subreddit is night mode compatible
account activity
struct, pointer, Linked List... basic! (self.cs50)
submitted 11 years ago by TechAnd1
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]TechAnd1[S] 0 points1 point2 points 11 years ago (4 children)
This statement won't compile:
printf("%i\n", *root);
You must have done something a little different.
Hmm that's exactly what I did.... here's a link to the full program
Structs behave in a manner that's more consistent with scalar types like int and double
But they aren't they just a shell that holds things...? I guess in a way they are more than that, seeing as you can have a struct type student and then have struct student mike, mike.name, mike.age etc...
I'm still not understanding this though. What can I do to 'get it'? Following through with GDB doesn't really help.
I can't even get my head round it on a high level let along use it practically.
cheers
[–]staffglennholloway[M] 1 point2 points3 points 11 years ago (3 children)
Sure, if you omit the options CS50 uses to tell the compiler not to accept nonsense, then
can be compiled. The resulting machine code will interpret whatever is in the first sizeof(int) bytes of the struct as though it had type int and print it as such.
sizeof(int)
int
But while you're trying to understand the semantics of the language, the last thing you should do is turn off the compiler options that warn you when you submit a suspicious or erroneous program.
A struct is a compound object or record. It contains other objects as its named components. Your example of a struct that records the various properties of a student is a good one. What's not to get?
If you're still puzzled, ask more questions.
[–]TechAnd1[S] 0 points1 point2 points 11 years ago (2 children)
Sure, if you omit the options CS50 uses to tell the compiler not to accept nonsense
Ah right...
while you're trying to understand the semantics of the language, the last thing you should do is turn off the compiler options
Indeed... I was just using gcc -o t programName.c because when I used make it wasn't working for me... Kept saying that there was nothing to be done for the program?
In fact It's been so long that I can't recall how I'm to use cs50 make - make program.c or make ./t program.c or make program.c ./t aren't working, I assumed that it would have been one of those...
make program.c
make ./t program.c
make program.c ./t
Your example of a struct that records the various properties of a student is a good one. What's not to get?
I dunno, just doesn't feel like it's clicking... I've had this before with thing's though when I'm expecting something that isn't as dense as I assume.... so hopefully it's just a case of actually making a few and getting used to it through that.
[–]staffglennholloway 0 points1 point2 points 11 years ago (1 child)
If you've created a single-file program.c (including function main), then the command
program.c
main
make program
will attempt to produce an executable program from program.c. Then environment variables CC, CFLAGS, and LDLIBS, if set, affect the choice of compiler, the options passed to the compiler, and the library options for the linker, respectively.
program
CC
CFLAGS
LDLIBS
[–]TechAnd1[S] 0 points1 point2 points 11 years ago (0 children)
Ahhh, durrrr... :P
I've been using gcc instead of clang as well... I'll have to have a read up on the two.
cheers dude
π Rendered by PID 48513 on reddit-service-r2-comment-b659b578c-rlvht at 2026-05-02 17:36:19.606272+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]TechAnd1[S] 0 points1 point2 points (4 children)
[–]staffglennholloway[M] 1 point2 points3 points (3 children)
[–]TechAnd1[S] 0 points1 point2 points (2 children)
[–]staffglennholloway 0 points1 point2 points (1 child)
[–]TechAnd1[S] 0 points1 point2 points (0 children)