Hello People,
I'm quite a bit struggling with Pointers. I just can't get my head around the whole matter of it.
The studybooks start to explain it from a startof point which is already beyond my knowledge so I was lagging behind right from the start.
Of course, after drilling myself by reading the chapters over and over again, along with helpfull youtube content, there eventualy is a certain basic knowledge on this in my head now, but I need some clarification or ratification of my assumptions and that I understand things right.
Also, if one has links to proven to be good Youtube content on this, I would be gratefull.
I found a video by an Indian woman explaining it in a way I could manage somewhat. But the accent, even though only less than normaly noticable, was distracting in a way I therefor needed a fraction of a second to understand the sentence, before being able to catch up.
I have a piece of code which contains a few pointer thingy's. So something to tear appart to see what it is doing.
Can someone explain step by step what is going on here?
#include <stdio.h>
void twofold (int *single, int *duble); //"double" is a prohibited word. Therefor "duble"
void twofold (int *single, int *duble)
{
*duble = 2 * *single;
*single = 4 * *duble;
}
void main()
{
int n=3, result ;
twofold (&n, &result);
printf("%6d %6d", n, result);
n = n+1;
twofold(&n, &result);
printf("%6d %6d", n, result);
}
I'm quite a bit struggling with Pointers. I just can't get my head around the whole matter of it.
The studybooks start to explain it from a startof point which is already beyond my knowledge so I was lagging behind right from the start.
Of course, after drilling myself by reading the chapters over and over again, along with helpfull youtube content, there eventualy is a certain basic knowledge on this in my head now, but I need some clarification or ratification of my assumptions and that I understand things right.
Also, if one has links to proven to be good Youtube content on this, I would be gratefull.
I found a video by an Indian woman explaining it in a way I could manage somewhat. But the accent, even though only less than normaly noticable, was distracting in a way I therefor needed a fraction of a second to understand the sentence, before being able to catch up.
I have a piece of code which contains a few pointer thingy's. So something to tear appart to see what it is doing.
Can someone explain step by step what is going on here?
#include <stdio.h>
void twofold (int *single, int *duble); //"double" is a prohibited word. Therefor "duble"
void twofold (int *single, int *duble)
{
*duble = 2 * *single;
*single = 4 * *duble;
}
void main()
{
int n=3, result ;
twofold (&n, &result);
printf("%6d %6d", n, result);
n = n+1;
twofold(&n, &result);
printf("%6d %6d", n, result);
}