K. Srinivasa Chary wrote: > char *s="",t; > > ... > scanf("%s",s); > You haven't really provided a place for scanf to store its output. char *s=""; Makes s equal to a pointer to a single byte of 0 stored somewhere in memory (potentially shared with "" or even other strings elsewhere in your program). It is NOT a buffer you are permitted to overwrite.