Forum Discussion
Altera_Forum
Honored Contributor
20 years agoglobal pointer assignment error
Nios 5.0.1
In global scope: char test[20]="teststring"; char *cp1 = &test[0]; //this works char *cp1; cp1 = &test[0]; //but this does not It all works inside a function, but not in global scope. Is this part of the anti-global variable campaign, or something I missed in my remedial C class?1 Reply
- Altera_Forum
Honored Contributor
Because the first assignment is done at compile time, and second assignment must be done at run time i.e. generates code. This is only allowed inside a function. Too early in the morning...