|
-
October 23rd, 2001, 05:27 AM
#1
Termination of character string array
How do I terminate character string array?
The following example does not work!!!
void main (void) {
int i;
char *workdays[]={"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "" };
// notice "" - empty string at the end of array
char **work_day;
work_day=workdays;
while (*work_day) printf("%d\n", i++);
exit(1);
}
This example will print numbers from 1 to xxx instead of printing from 1 to 6.
I need explanation why "" at the end of array isn't treated as \n?
Tomislav
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|