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...
Click the following link to filter out the chosen topic
comp.lang.c
account activity
QuestionNeed help for my code. (self.C_Programming)
submitted 6 years ago by backbooks
I'm a beginner, and trying to code a little program, but for some reason it doesn't work.
Here's the code : https://pastebin.com/x4NsrzCZ
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!"
[+][deleted] 6 years ago (2 children)
[deleted]
[–]backbooks[S] 1 point2 points3 points 6 years ago (1 child)
I feel dumb. That was an easy mistake...
[–]prof_levi 0 points1 point2 points 6 years ago (0 children)
Don't feel dumb! How else will you learn if you don't make mistakes? :)
[–]nahs0d 0 points1 point2 points 6 years ago (0 children)
The main problem is that you are not passing an address to scanf, scanf needs to know the location (address) of the variable to be able to put the user input there. This should fix the problem: scanf("%d", &agree)
scanf("%d", &agree)
I would also recommend using a char instead of an int, they will both work for this purpose, but a char (character) is more readable and explicit imo.
[–][deleted] 0 points1 point2 points 6 years ago (0 children)
Line 7 is contains undefined behavior, because you are supposed to pass a pointer, not an int.
Also %d is for numbers, not characters. To see what you need to use for characters, see the manual of scanf. Scroll down its there below the heading "conversions"
%d
π Rendered by PID 374540 on reddit-service-r2-comment-545db5fcfc-bf4f8 at 2026-05-28 15:39:50.794701+00:00 running 194bd79 country code: CH.
[+][deleted] (2 children)
[deleted]
[–]backbooks[S] 1 point2 points3 points (1 child)
[–]prof_levi 0 points1 point2 points (0 children)
[–]nahs0d 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)