stupid compilers
Martin Wendel
martin at prodix.liu.se
Fri Aug 31 19:08:27 AEST 1990
Can anyone explain to me why this piece of code is O to run:
#include <stdio.h>
#include <strings.h>
main()
{
char line[];
char *tmp = "1234";
strcpy(line, tmp);
printf("%s\n", line);
}
when this pboduce a segmentation fault:
#include <stdio.h>
#include <strings.h>
main()
{
char *line;
char *tmp = "1234";
strcpy(line, tmp);
printf("%s\n", line);
}
I have a sparcstation 1+ and run SUNOS 4.03 and I have tried the
Sun C compiler and the GNE C compiler with and without the -ansi
flag set, but they all behave the same.
Thanks in advance.
_____________________________________________________________
< Martin Wendel > martin at solix.udac.uu.se >
> Postmaster at UDAC < Martin.Wendel at UDAC.UU.SE <
< Uppsala University - > Postmaster at UDAC.UU.SE >
> Data Centre < Phone: 018 - 18 77 80 <
< Sysslomansgatan 21 > Int: +46 18 18 77 80 >
> S-750 02 Uppsala <---------------------------------<
< SWEDEN > /\/\ \ \/ / >
>_________________________<___________/ /\ \_\/\/___________<
More information about the Comp.lang.c
mailing list