Date: Wed, 21 Dec 94 12:02:48 PST From: Curtiss Cicco <1CMC3466 AT ibm DOT MtSAC DOT edu> Organization: Mt. San Antonio College Subject: Undeclared string variable To: djgpp AT sun DOT soe DOT clarkson DOT edu In this C book I am working through, I've come to some code that won't compile. I get an error msg saying 'str' is undeclared, here's the code that is giving me problems: ------------------------------------------------------------------------ #include main() { /* allocate memory for a 100 character string */ char *string; if (( str = (char *) malloc(100)) == NULL) { printf( "Not enough memory to allocate buffer\n"); exit(1); } printf( "String was allocated!" ); return 0; } ------------------------------------------------------------------ I also included malloc.h to see if that would work, but it didn't. Is there something I am failing to include that is keeping the code from compiling? -CmC