Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!harpo!seismo!hao!csu-cs!cobb From: cobb@csu-cs.UUCP Newsgroups: net.lang.c Subject: mixing pointers and arrays Message-ID: <2332@csu-cs.UUCP> Date: Thu, 28-Jul-83 16:11:27 EDT Article-I.D.: csu-cs.2332 Posted: Thu Jul 28 16:11:27 1983 Date-Received: Fri, 29-Jul-83 06:48:52 EDT Lines: 40 Consider the two routines: extern char *yytext; main () { stat (); printf ("%s\n",*yytext); } and char yytext [10]; stat () { yytext [0] = 'y'; yytext [1] = 'e'; yytext [2] = 'a'; yytext [3] = 'r'; yytext [4] = '\0'; } These two routines exist in different modules, and are compiled separately and then linked and loaded. However, every time I try to execute the routine, I get an execution error. From reading the C manual, the implication is that yytext is implemented as a pointer to some storage locations, and can therefore be treated as such. This is reinforced by the legal program segment . . . char ch [n]; char *chptr; chptr = ch; . . which results in chptr being assigned the base location of the array 'ch'. Why then do the first routines blow up? Thanks S. Cobb !hao!csu-cs!cobb