- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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...
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page