This code, straight out of a book, isn't compiling:
f() { char a[] = "Hello, world!"; }
Perhaps you have a pre-ANSI compiler, which doesn't allow initialization of ``automatic aggregates'' (i.e. non-static local arrays, structures, and unions). As a workaround, you can make the array global or static (if you won't need a fresh copy during any subsequent calls), or replace it with a pointer (if the array won't be written to). (You can always initialize local char * variables to point to string literals, but see question 1.32.) If neither of these conditions hold, you'll have to initialize the array by hand with strcpy when f is called. See also question 11.29.
Read sequentially: prev next up top
This page by Steve Summit // Copyright 1995 // mail feedback