Hey ,i was trying to assign a value to a string.
For example lets say: int X; x=10;
then when we do X=40, the value 40 overwrites the value 10;
SO I was doing the same for string.
my code was :
Code:
char *temp;
temp=" ";
temp[0]='a'; temp[1]='r'; temp[2]='t'; temp[3]='\0';
printf("\n*%s--------->length is %d",temp,strlen(temp));
temp=" ";
temp[0]='i'; temp[1]='t'; temp[2]='\0';
printf("\n*%s--------->length is %d",temp,strlen(temp));
return 1;
In unix it compiles without errors:but crashes when you run it.
Was using gcc -ansi -pedantic -Wall -o runFile test.c
though In Microsoft visual c++ 2003 it compiles and runs and in dev c it compiles but cant run.
CAN SOME ONE HELP ME CORRECT MY MISTAKE ABOUT SO IT CAN RUN IN UNIX ?
thanx alot