I was just coding a test example and this worked (if it makes any difference, I'm programming in C):
Code:
#include <stdio.h>
int num = 2;
int *ptrnum;
ptrnum = #
*ptrnum = 3;
int main()
{
printf("%d", *ptrnum);
return (0);
}
This worked perfectly and printed to the screen, "3". But then I tried to do this same thing with a string:
Code:
#include <stdio.h>
char name[] = "John";
char *ptrname;
ptrname = &name;
*ptrname = "Tom";
int main()
{
printf("%s", *ptrname);
return (0);
}
This brought up one error and a warning. The error was that the level of indirection was incorrect (maybe not in that specific wording). What is the difference? I only change data types? How would you do this with strings that I was trying to do? Thanks.