I think they fixed it... I'm taking the course now and besides the main lecture, they have short videos explaining things just like these. Actually they have a few videos just about pointers. Sorry you didn't have access to that.
Sami Rehmann We could do that, but then we wouldn't be able to have our own Code::Blocks window beside the video to work alongside him or type down any notes (unless we had a second monitor). And his videos show the entire view of his desktop, most of which is unnecessary, it'd be better if he just zoom into the code space which actually is the only important part of the screen.
+Don't look for me Not really the greatest tip, but if you want to have Code Blocks and this video side-by-side, enlarge the video(not fullscreen) and then zoom in the website using ctrl+mouse scroll up. This should make it easier to work with both the browser and code blocks side-by-side without squinting your eyes.
maybe you should consider different career, bcs it took you 19years longer to understand beginners concepts. Epic. Oh, btw, video isn't accurate so good luck figuring out language basics
Very helpful summary, clearly explains the basics of pointers by using approachable language and examples. It was refreshing to have someone begin from the lowest level possible and moving up to the more complex uses, unlike most videos and web articles. The format also makes it very easy to follow along and actually code a lot of this yourself as he leads on the video. Great video for someone looking for more information on the basics of pointers.
You're the best. I got nothing else to say. Your explanations are simple, to the point and covers all the other respective details about the topic too. My teacher worked so hard to explain it in two weeks, just made us - (students) more confused. Thanks a lot I learnt about pointers here than in my class.
Great description, I know I found this topic to be difficult when I started learning C and many of my classmates still struggle with this topic sometimes. Using a simple analogy such as the house with an address example really helped me to get my head around this topic when I first learned it. I feel like I initially suffered due to the mentality of just moving the syntax around until it compiled/worked without fully understanding it. Starting at such a basic level then moving to syntax, then examples really helped me learn this topic. Thanks for the video!
Pointers are so confusing concept that I had to watch tutorials 42 and 43 (which were way more informative than the lectures by the way) at least twice. I love how your tutorials are so consistent to the things we discussed on my lectures.
just saved me for my finals. starting at the basics and working through them simply has made it easier for me to refresh my knowledge and apply it practically
I have a question. checkout the address in 3 timelines: 4:19------0028FFIC 7:15-----0028FF18 0028FF18 8:08-----0028FFIC 0028FFIC 0028FF18 My question is why the pointer of tuna changed the second time, and at the third time it changed back. really confusing.
4:19 : 0028FF1C (hexadecimal) = 2686748 (decimal number) 7:15 : 0028FF18 (hexadecimal) = 2686744 (decimal number) As you can see the number has decreased by the value of 4. to be correct it has decreased by 4 Bytes (every computer adress can store one byte) He stored an integer, integers are 32 bit = 4 bytes. because the first adress (2686748) was already used after he used it at 4:19 , C searched for the next free 4 bytes to store the integer. In that case it was 2686748 - 4 = 2686744 (second adress). But I dont know why it decreased, I just learned this stuff this semester.
Great video, but a small little note for some viewers: The memory address *is* a number. It is a hexadecimal (base 16) number. In fact this is important, because we do arithmetic operations on them. Add 1 to the address, and whoop, you are at the next byte in your memory, and so on.
The problem is pointer arithmetic is done at the level of the sizeof the type it is pointing to. +1 to an address from an int pointer would be +4 on the number. I like to think of them as some special sort of numbers since you can't add/multiply/divide two addresses, subtraction result is divided by the size and whatnot.
wow, I read a book about C that explained a lot about pointers but it never actually told me that it's just a variable for an address. Or maybe I just don't remember that haha. That explains it so well, thanks!
Your tutorials are awesome... Short and informative in the simplest possible way.. Thanks man... Just a request , please make the font size bigger next time you make any tutorial series on programming.. :)
Another way to print the address of a variable : (used in some books) is by using %u instead of %p check this code out : #include #include int main() { int tuna=4; printf(" %p \t %u", &tuna, &tuna); return 0; }
Note to viewers: Like %s expects a char *, %p expects a void *, NOT an int *. While his code may work on some systems, there are others it will crash on. You need to cast the int * to a void * first, eg: printf("%p ", (void *) &tuna);
Sebastian Ramadan it would crash if you wrote it like he did but without the "&", if you wrote it like this: printf("%p ", tuna); your compiler would ask if you meant a void instead of an int
Lars Db It's invalid to suggest that invoking undefined behaviour definitively results in crashes; in many real life scenarios it doesn't... for example signed integer overflow, occasionally small buffer overflows and misaligned accesses on x86 will often "work" rather than "crashing". In fact, what you mentioned is another example that won't typically cause immediate crashes (though it may later on down the track, such is the nature of undefined behaviour)... See: ideone.com/gQ3CPh. *If you say that the behaviour results in a crash, then it is no longer undefined behaviour; it's behaviour that's defined to cause crashes*. What crashes on your system might "work correctly" (whatever that means, considering the nature of undefined behaviour) on my system... Do you understand? It's important to note that C won't necessarily save you by providing a nice clean crash for you to debug every time you do something wrong.
Lars Db Now that you know this information, it should be easy enough to find a teacher who knows C and can teach you. Questions such as "Why don't all undefined behaviours cause crashes?" should illuminate the gold from the grit. Best of luck to you :)
Lars Db ... and in the meantime, don't forget to ensure arguments corresponding to a %p directive are void *... and say g'day to the Linguist Llama for me :)
If you are printing out the pTuna's adress (8.45) why is it the same as its value? should'nt the adress to pTuna be another adress and not the same adress as tuna?
Bucky, it would be awesome if u could zoom ur screens like on the older videos using some screen capture softwares. I understand that it's a hell lot of jobs to do looking at the volumes of tutorials u are making everyday, but ppl like me who are trying to learn on the go on cell phones, it's way difficult. Thank you for ur awesome tutorials though.
I don't know why I'm watching this, but your claim that memory addresses cannot be stored as integers is completely wrong. ( 5:05 ) "It can't be an integer because it has characters in it." WTF? Memory addresses are typically represented as integers in hexadecimal notation, but can be represented as base 10 numbers or even base 2 numbers. A memory address is an integer, always, and its maximum size depends on the CPU architecture.
"First time watcher". POINTERS: Now that's what I'm talking bout... GOOD STUFF, thank you. Clear & Concise = I'm hooked. Make room for another sUbScRiPtIoN. p.s. And it's in good old (audible) English too. Can't beat that :O) Cheers
Hey Bucky. Can you make your fonts in your tutorials any smaller. Looks like the Tuna fish ran off with your larger fonts. Looks as though I need magnifying glass to view your tutorials. :-)
so what will happen if we want to know where the computer saves our variable is and we dont use %p, but %d. i've tried, it shows a random numbers and i dont know what it is. plz reply this comment if u know about this
So hey, I got this as my problem can you help me to solve this? main( ) function In the main( ) function, the program will: call a user defined function input( ) passing two pointers, namely previous_reading* and current_reading* Upon return of the input( ) function, main( ) will call for another user defined function named calculate( ). calculate( ) will take the difference of current_reading and previous_reading values (current_reading - previous_reading). The main( ) will then print on the screen the bill amount based on the returned value from calculate( ). how to return the input() function to main()? I dont get it.
cs50 is way too complicated for beginners, they don't simplify anything, i remember one of the shorts video when Doug, was explaining the pass by value and by reference, I didn't understand shit! they intentionally make everything complicated. honestly it's not the ideal path for beginners.
It's really hard to understand what you're doing when you can't see it. Please zoom in on the code when you're writing it so we could get a better look at it. Other than that, Nobody explains it better than you do! :D
hi been workig on this tutorial for quit a while and saw this pointer video and got a doubt can any one menction the difference between the below two printf lines int a = 100; printf("%p",a); printf{"%p", &a); both show the different addresses so both are good to use or just have to use the second printf
The p flag tells C to display the output in hexadecimal. I think your first printf statement which contains the integer value 100 is put out as that same value but in hexadecimal format. It is not another address for the variable a but rather the number 100 converted from base 10 to base 16. Your second printf statement displays the actual memory address of the variable a.
They can be used for virtually anything, but you should only use them when you really need them - otherwise, when you can just use straight objects with standard containers - use that. When you can use references - use that.
When you have, for example, a large array... think 2000 elements and want to pass that array to a function. Instead of passing the whole array (2000 elements * sizeof(element)) you simply pass a pointer to the start of the array. In fact, in C, there is no other way to pass an array to a function. The same goes for large data structure. Here's an example: typedef struct LargeStruct { // ... 2000 bytes of data } LargeStruct; void passWithoutPointer(LargeStruct struct) { //
techincally 0028FF1C is a number. It's a 32 bit integer. Just because it doesn't have 10 symbols to choose from (0,1,2,3,4,5,6,7,8,9) it can still be a number. Coming from a nitpicking math nerd learning programming
* is like telling the pointer to look at the address it is pointing and get that value. ** would basically do that twice. Look at address -> Get the value -> Look at that value as an address -> Get the value from that latter address
Not giving the correct output with online compiler or is there anything wrong in my code. If anyone can find a mistake in the code below pls let me know thanks. #include #include #include #include #include int main() { int coffee = 19; printf("Address \t Name \t Value "); printf("%p \t %s \t %d ", &coffee, "coffee", coffee); int * pCoffee = &coffee; printf("%p \t %s \t %d ", pCoffee, "coffee", coffee); printf("%p \t %s \t %d ", &pCoffee, "pCoffee", pCoffee); }
The problem is simple, this line: printf("%p \t %s \t %d ", &pCoffee, "pCoffee", pCoffee); should be changed to printf("%p \t %s \t %d ", pCoffee, "pCoffee", *pCoffee); pCoffee is already a pointer so you don't have to get the reference to it with '&' ('&pCoffee' would actually be a pointer to a pointer) Also, since 'pCoffee' is a pointer, simply giving that to printf would print out the actual address. You want to go to that address and get that value (that's what '*' is for). Hope this helped!
I came here because goddamn Harvard's CS50 can't explain this, thank you so much
I think they fixed it... I'm taking the course now and besides the main lecture, they have short videos explaining things just like these. Actually they have a few videos just about pointers. Sorry you didn't have access to that.
18 dislikes? why? .. This video explained me more in 10 mins then my professor could in 10 weeks.. jeez (y) keep up the good work man..
Apparently those ppl don't like tuna
Maybe because his code is too small? Idk, I have trouble with it at first but I'm fine with it now
the dislikes are from professors who have some skill issues in teaching
I don't know why so many people are complaining. If you watch these videos in 1080p and in FULLSCREEN , you would see everything just fine .
3rd world problems, can't run at 1080p . Broadband ;_;
San Dé i have slow internet i use 360 or 480 max but these ones i can watch on 720 1.25 speed with no prob.
Sami Rehmann We could do that, but then we wouldn't be able to have our own Code::Blocks window beside the video to work alongside him or type down any notes (unless we had a second monitor). And his videos show the entire view of his desktop, most of which is unnecessary, it'd be better if he just zoom into the code space which actually is the only important part of the screen.
+Don't look for me Not really the greatest tip, but if you want to have Code Blocks and this video side-by-side, enlarge the video(not fullscreen) and then zoom in the website using ctrl+mouse scroll up. This should make it easier to work with both the browser and code blocks side-by-side without squinting your eyes.
+Sami Rehmann actually my problem was that I was wearing sunglasses inside, took them off. . . Perfect!
9:31, "so the last thing I want to POINT out is"
this motivated me even more to watch it
I've been a C novice for, like, 20 years. This is helping me to finally understand pointers. I really liked this an your Git course. Thanks!
maybe you should consider different career, bcs it took you 19years longer to understand beginners concepts. Epic. Oh, btw, video isn't accurate so good luck figuring out language basics
This was a good video.
(puts on sunglasses)
You've definitely given me a few pointers.
YEAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHH!
XDD
I named my cat Bucky because they both love tuna equally.
Very helpful summary, clearly explains the basics of pointers by using approachable language and examples. It was refreshing to have someone begin from the lowest level possible and moving up to the more complex uses, unlike most videos and web articles. The format also makes it very easy to follow along and actually code a lot of this yourself as he leads on the video. Great video for someone looking for more information on the basics of pointers.
You're the best. I got nothing else to say. Your explanations are simple, to the point and covers all the other respective details about the topic too.
My teacher worked so hard to explain it in two weeks, just made us - (students) more confused. Thanks a lot I learnt about pointers here than in my class.
this is the clearest explanation of pointers that I have seen. Professors need to show this video
Bro why can I find free, simple and easy tutorials on UA-cam but my actual lecturers and tutors can’t do any of that! Bravo!
Great description, I know I found this topic to be difficult when I started learning C and many of my classmates still struggle with this topic sometimes. Using a simple analogy such as the house with an address example really helped me to get my head around this topic when I first learned it. I feel like I initially suffered due to the mentality of just moving the syntax around until it compiled/worked without fully understanding it. Starting at such a basic level then moving to syntax, then examples really helped me learn this topic. Thanks for the video!
Pointers are so confusing concept that I had to watch tutorials 42 and 43 (which were way more informative than the lectures by the way) at least twice. I love how your tutorials are so consistent to the things we discussed on my lectures.
very helpful, thank you so much! trying to study for a final
Bucky you are just greatest teacher, every teacher should like you. You make such a difficult thing the simplest
just saved me for my finals. starting at the basics and working through them simply has made it easier for me to refresh my knowledge and apply it practically
final exam after 7 hours trying to finish the whole tutorial which is 6 hours long hhhhhhh
wut
***** it went well :)
Amen I'm in the same boat now. Final Exam on Monday - 5 chapters to catch up on...
Vincent Vuong hahah good luck bro, u can do it :)
You will make it if you are an engineer :p
I really love your work.... I just wanted to say thanks, you're a great teacher.
I have a question. checkout the address in 3 timelines:
4:19------0028FFIC
7:15-----0028FF18
0028FF18
8:08-----0028FFIC
0028FFIC
0028FF18
My question is why the pointer of tuna changed the second time, and at the third time it changed back. really confusing.
4:19 : 0028FF1C (hexadecimal) = 2686748 (decimal number)
7:15 : 0028FF18 (hexadecimal) = 2686744 (decimal number)
As you can see the number has decreased by the value of 4.
to be correct it has decreased by 4 Bytes (every computer adress can store one byte)
He stored an integer, integers are 32 bit = 4 bytes.
because the first adress (2686748) was already used after he used it at 4:19 , C searched for the next free 4 bytes to store the integer.
In that case it was 2686748 - 4 = 2686744 (second adress).
But I dont know why it decreased, I just learned this stuff this semester.
Great video, but a small little note for some viewers:
The memory address *is* a number. It is a hexadecimal (base 16) number. In fact this is important, because we do arithmetic operations on them. Add 1 to the address, and whoop, you are at the next byte in your memory, and so on.
The problem is pointer arithmetic is done at the level of the sizeof the type it is pointing to. +1 to an address from an int pointer would be +4 on the number.
I like to think of them as some special sort of numbers since you can't add/multiply/divide two addresses, subtraction result is divided by the size and whatnot.
wow, I read a book about C that explained a lot about pointers but it never actually told me that it's just a variable for an address. Or maybe I just don't remember that haha. That explains it so well, thanks!
what a crystal clear explanation! well done sir
Bravo Bucky what you explained in less than 10 mins.. what my instructor could not in hours if not days! lol THANKS Bucky!
a pointer is a special type of variable that can hold the memory address of a variable.
Your tutorials are awesome... Short and informative in the simplest possible way.. Thanks man... Just a request , please make the font size bigger next time you make any tutorial series on programming.. :)
Another way to print the address of a variable : (used in some books) is by using
%u instead of %p
check this code out :
#include
#include
int main()
{
int tuna=4;
printf(" %p \t %u", &tuna, &tuna);
return 0;
}
It seems that "%p" prints out the memory address in hex form, while "%u" prints out the memory address in decimal form
both %p and %u stand for pointers?
no %u is for unsigned integer data types. they are not same thing.
thank you so much you have dave my life i lost one class about pointer and now i'm okay you are the best
Your videos deserve more views than others at least you build my concept of programming.
Thanks man, you make this complicated topic really easy to understand.
Thank you so much for un-confusing me. Trying to learn C on my own and avoid "bad habits".
Note to viewers: Like %s expects a char *, %p expects a void *, NOT an int *. While his code may work on some systems, there are others it will crash on. You need to cast the int * to a void * first, eg: printf("%p
", (void *) &tuna);
Sebastian Ramadan it would crash if you wrote it like he did but without the "&", if you wrote it like this: printf("%p
", tuna); your compiler would ask if you meant a void instead of an int
Lars Db It's invalid to suggest that invoking undefined behaviour definitively results in crashes; in many real life scenarios it doesn't... for example signed integer overflow, occasionally small buffer overflows and misaligned accesses on x86 will often "work" rather than "crashing". In fact, what you mentioned is another example that won't typically cause immediate crashes (though it may later on down the track, such is the nature of undefined behaviour)... See: ideone.com/gQ3CPh. *If you say that the behaviour results in a crash, then it is no longer undefined behaviour; it's behaviour that's defined to cause crashes*. What crashes on your system might "work correctly" (whatever that means, considering the nature of undefined behaviour) on my system... Do you understand? It's important to note that C won't necessarily save you by providing a nice clean crash for you to debug every time you do something wrong.
Sebastian Ramadan I guess you're right, well it did show plenty of error messages and finally crashed, I guess it was my software.
Lars Db Now that you know this information, it should be easy enough to find a teacher who knows C and can teach you. Questions such as "Why don't all undefined behaviours cause crashes?" should illuminate the gold from the grit. Best of luck to you :)
Lars Db ... and in the meantime, don't forget to ensure arguments corresponding to a %p directive are void *... and say g'day to the Linguist Llama for me :)
Final exam on 3rd January and I'm practicing whole tutorials best teacher in programming.
appreciate it my brother, you are goated for this
If you are printing out the pTuna's adress (8.45) why is it the same as its value? should'nt the adress to pTuna be another adress and not the same adress as tuna?
Bucky, it would be awesome if u could zoom ur screens like on the older videos using some screen capture softwares. I understand that it's a hell lot of jobs to do looking at the volumes of tutorials u are making everyday, but ppl like me who are trying to learn on the go on cell phones, it's way difficult. Thank you for ur awesome tutorials though.
You program on your phone?
@@gollumei Well some of us do. And it's not that, it's really small and although you can read it, you have to put your face closer to the monitor.
I generally thank you for your all tutorial Mr
Such an informative video. Please keep making more :)
Super cool tutorial. Explained step by step and easy to understand. Thanks for sharing this if us
I don't know why I'm watching this, but your claim that memory addresses cannot be stored as integers is completely wrong. ( 5:05 ) "It can't be an integer because it has characters in it." WTF? Memory addresses are typically represented as integers in hexadecimal notation, but can be represented as base 10 numbers or even base 2 numbers. A memory address is an integer, always, and its maximum size depends on the CPU architecture.
You enlightened all my doubts. Thanks man !!
when i ran program.. value in pointer should be the address of given variable...but it is showing wrong address...plz help me.
Thank you! You are amazing teacher!!!
Great Video, helped me heaps! Thanks.
man can you please expand your screen so that we can also see what are you typing and running ? The font is so tiny that I can hardly read :(
Nice tutorial! Came here from cython not C but it is still very useful!
what if you had a pointer to pointer?
"1 thing i want to point out"
that pun
Really great explanation on pointers
"First time watcher". POINTERS: Now that's what I'm talking bout... GOOD STUFF, thank you. Clear & Concise = I'm hooked. Make room for another sUbScRiPtIoN. p.s. And it's in good old (audible) English too. Can't beat that :O) Cheers
damn, that was some phenomenal explaining
Thank you so much for the clear explanation.
Hey Bucky. Can you make your fonts in your tutorials any smaller. Looks like the Tuna fish ran off with your larger fonts. Looks as though I need magnifying glass to view your tutorials. :-)
so what will happen if we want to know where the computer saves our variable is and we dont use %p, but %d. i've tried, it shows a random numbers and i dont know what it is. plz reply this comment if u know about this
Is a pointer like the "new" keyword in Java? Creating a memory address to reference an Object?
Thanks man! You're pure awesome! :D
Great tutorial! What IDE did you use in this video?
Marco Raguseo he is using codeblocks
Thanks bro , This explained the pointer for me
So hey, I got this as my problem can you help me to solve this?
main( ) function
In the main( ) function, the program will:
call a user defined function input( ) passing two pointers, namely previous_reading* and current_reading*
Upon return of the input( ) function, main( ) will call for another user defined function named calculate( ).
calculate( ) will take the difference of current_reading and previous_reading values (current_reading - previous_reading).
The main( ) will then print on the screen the bill amount based on the returned value from calculate( ).
how to return the input() function to main()? I dont get it.
So if I need to point to a typedef struct and the parameter of the function I have to call is int *var what would I do?
if only i could like this video for 5 million times
press windows button and then +
it will zoom so you can see easily
what if i want to have this pointer in binary to encrypt a file on my computer using DES?
amazing tutorial! thank you so much
The characters are too small. I can't see the screen.
you explained this way better then cs50.
cs50 is way too complicated for beginners, they don't simplify anything, i remember one of the shorts video when Doug, was explaining the pass by value and by reference, I didn't understand shit!
they intentionally make everything complicated.
honestly it's not the ideal path for beginners.
Best explanation ever!!
YAS i finally understand!
thanks man
"We can't store memory address in int because it has characters in it" L0L
The weirdest thing is you don't even need the * before pTuna, and the code will still work identically. Someone explain?
I can just access addresses that I create in my program?Or I can access whatever I have in my computer?
+Guiango Thinoiras I think you can access anything. You just make code::blocks look at an address and it tells you what's in it.
This seems like good stuff. Too bad I can't see what he is doing with that font size.
It's really hard to understand what you're doing when you can't see it. Please zoom in on the code when you're writing it so we could get a better look at it. Other than that, Nobody explains it better than you do! :D
You HAVE to watch it in HD, and you didn't need to on his earlier tutorials... Yeah I'm confused too lol
What does the address of memory address means.
can we convert &ptuna to a variable like int *pptuna = &*ptuna
so would printf("%d", *&age_variable); work?
Great explanation!!!
thenewboston man you sure do like tuna
What is the point of pointer when we can go easy with array🤔🤔?
hi been workig on this tutorial for quit a while and saw this pointer video and got a doubt
can any one menction the difference between the below two printf lines
int a = 100;
printf("%p",a);
printf{"%p", &a);
both show the different addresses
so both are good to use or just have to use the second printf
The p flag tells C to display the output in hexadecimal. I think your first printf statement which contains the integer value 100 is put out as that same value but in hexadecimal format. It is not another address for the variable a but rather the number 100 converted from base 10 to base 16.
Your second printf statement displays the actual memory address of the variable a.
So use second printf
not quite understand, can you explain a little bit more. thank you.
is %p stand for pointer?
why theres a pTuna and then below &pTuna
scaling is too small on my 14" screen can't rread the code
What if want to get the address of the Pointer itself?
Omar Adel &pTuna
so like message address is...,,. an address of an address? (figuratively speaking)
So much better than my professor
eating Tuna will never be the same again.
From what kind of programs can be "pointers" will be useful?
They can be used for virtually anything, but you should only use them when you really need them - otherwise, when you can just use straight objects with standard containers - use that. When you can use references - use that.
Man you're the best
Guys can I ask that pointer is use for? Any example?
When you have, for example, a large array... think 2000 elements and want to pass that array to a function. Instead of passing the whole array (2000 elements * sizeof(element)) you simply pass a pointer to the start of the array. In fact, in C, there is no other way to pass an array to a function. The same goes for large data structure. Here's an example:
typedef struct LargeStruct {
// ... 2000 bytes of data
} LargeStruct;
void passWithoutPointer(LargeStruct struct) { //
techincally 0028FF1C is a number.
It's a 32 bit integer.
Just because it doesn't have 10 symbols to choose from (0,1,2,3,4,5,6,7,8,9) it can still be a number.
Coming from a nitpicking math nerd learning programming
what program are u using??
its codeblocks
what is the difference between * and **?
* is like telling the pointer to look at the address it is pointing and get that value.
** would basically do that twice. Look at address -> Get the value -> Look at that value as an address -> Get the value from that latter address
Not giving the correct output with online compiler or is there anything wrong in my code. If anyone can find a mistake in the code below pls let me know thanks.
#include
#include
#include
#include
#include
int main() {
int coffee = 19;
printf("Address \t Name \t Value
");
printf("%p \t %s \t %d
", &coffee, "coffee", coffee);
int * pCoffee = &coffee;
printf("%p \t %s \t %d
", pCoffee, "coffee", coffee);
printf("%p \t %s \t %d
", &pCoffee, "pCoffee", pCoffee);
}
The problem is simple, this line:
printf("%p \t %s \t %d
", &pCoffee, "pCoffee", pCoffee);
should be changed to
printf("%p \t %s \t %d
", pCoffee, "pCoffee", *pCoffee);
pCoffee is already a pointer so you don't have to get the reference to it with '&' ('&pCoffee' would actually be a pointer to a pointer)
Also, since 'pCoffee' is a pointer, simply giving that to printf would print out the actual address. You want to go to that address and get that value (that's what '*' is for).
Hope this helped!
I am just learning programming, but it looks like pointer variables are similar to "PEEK" in the BASIC programming language.
Great tutorial
Explain how to use pointers in functions
Sorry but Iam not getting the Same result , as ptuna value is address of tuna ,but Iam getting some other value
manoj y it your taking about the memory location then it will be vary from person to person depending on how you have your computer setup
thank god i got it now ,instead of using %p i used %d
printf("%p \t %s\t %p
",&ptuna,"ptuna",ptuna);
thanks spiderman for helping hand
no, it's the same value but in decimal
really helpful thank you
Screen size too small to be interesting.
Bucky Roberts bhaiya, tum bhagwaan ho!
I don't even know why I'm watching this. I know pointers and I don't even use C/C++ anymore.
Maybe just because Bucky is awesome.
I use these to refresh my memory before classes start :P
***** For what we did, I didn't need to refresh anything. I am more like the "Oh, we are going to learn it! Better learn everything beforehand!"
Thank you Bucky........