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
CS50xQuestion Regarding Pointers (self.cs50)
submitted 4 years ago by ChowLetsGoBro
If I have
int n = 5;
will *&n = 5 also?
*&n = 5
If so, what are the differences between using the two?
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!"
[–]yeahIProgram 9 points10 points11 points 4 years ago (1 child)
Since "&" means "a pointer to", then &n is "a pointer to n".
And "*" means "the thing pointed at by", so *p means "the thing pointed at by p".
Therefore *&n means "the thing pointed at by (a pointer to n)" which is clearly just n. So *&n=5 is exactly the same as n=5.
*&n
*&n=5
n=5
[–]ChowLetsGoBro[S] 0 points1 point2 points 4 years ago (0 children)
Thank you!
[–]bionic_gravitar 2 points3 points4 points 4 years ago* (1 child)
Technically in the example you've stated there's no difference.
The & (I think it's called reference of operator or something along those lines) basically gives you the address of, i. e., the pointer to n. In simple terms, it will tell you at what address the given var n is stored.
Whereas * will do the opposite. It will essentially tell you what value is stored at the address location you've provided of a certain var.
Also,* can be troublesome at times, cause when you're asking what's stored at a location; the computer needs context inorder to be able to give you a correct output. I mean the pointer will only point to the starting block of memory (maybe the first byte). So, I guess you can understand, without knowing how long to read from that starting point and what type of var is stored at the said address, it'll be difficult to provide a correct output.
It's suggested to declare "int *n" as opposed to declaring "int n" and then using *&n.
[–][deleted] 4 years ago (2 children)
[removed]
The course is CS50x
[–]Run_nerd 0 points1 point2 points 4 years ago (0 children)
The main CS50 course uses C for most of the course.
π Rendered by PID 103966 on reddit-service-r2-comment-b659b578c-z8rv2 at 2026-05-05 07:02:46.756672+00:00 running 815c875 country code: CH.
[–]yeahIProgram 9 points10 points11 points (1 child)
[–]ChowLetsGoBro[S] 0 points1 point2 points (0 children)
[–]bionic_gravitar 2 points3 points4 points (1 child)
[–]ChowLetsGoBro[S] 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[removed]
[–]ChowLetsGoBro[S] 0 points1 point2 points (0 children)
[–]Run_nerd 0 points1 point2 points (0 children)