0

I'm learning how to use pointers in C, but my textbook doesn't do a good job explaining them. Given a pointer int * ptr; what is the difference between:

   ptr=
  *ptr=
  &ptr=

also when using scanf should I use scanf("%d",&ptr) or scanf("%d",ptr)?

  • 2
    "... my textbook doesn't do a good job explaining them" --> new book – Support Ukraine Jan 10 '20 at 11:33
  • try printing all 3.. – Andy_101 Jan 10 '20 at 11:34
  • 2
    Does this answer your question? [C Pointers: \*ptr vs &ptr vs ptr](https://stackoverflow.com/questions/25044422/c-pointers-ptr-vs-ptr-vs-ptr) – Andy_101 Jan 10 '20 at 11:35
  • 1
    [Pointers in C: when to use the ampersand and the asterisk?](https://stackoverflow.com/questions/2094666/pointers-in-c-when-to-use-the-ampersand-and-the-asterisk) and [Understanding pointers in C](https://stackoverflow.com/questions/10187510/understanding-pointers-in-c) also answer your question in great detail. The `scanf` part will become clear once you understand pointers in general. For `scanf`/`printf` formatting help, look [here](http://www.cplusplus.com/reference/cstdio/scanf). – 0x4d45 Jan 10 '20 at 11:43
  • @Andy_101 Yes, thank you, I don't know why I couldn't find it – Pietro Alessandrini Jan 10 '20 at 11:46

0 Answers0