The snippet below (or similar) compiles and runs OK but I am using Visual Studio C++ compiler. Are the lines where .nameFirst and .nameLast assigned kosher in ANSI C?
Also I am concerned about the memory allocation for these string constants. Does the runtime system put them on the heap? It doesn't seem that they are really constants since they are not defined before runtime.
Thanks,
jvh
Code:#include "stdlib.h" typedef struct { unsigned id; char* nameFirst; char* nameLast; } myList; int main(int argc, char* argv[]) { myList* myListP; myListP = (mylist*) calloc(10, sizeof(myList)); myListP[0].nameFirst = "Jack"; strcpy(myListP[0].nameLast = "Aubrey"; }