linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* is it a buf or what?
@ 2002-06-08 10:33 Mohammed Khalid Ansari
  2002-06-08 12:03 ` Glynn Clements
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mohammed Khalid Ansari @ 2002-06-08 10:33 UTC (permalink / raw)
  To: linux c programming mailing list


Hi,

I had written a small program as follows...

#include <stdio.h>

int main()
{
	char	*ptr;
	
	strcpy (ptr, "khalid");
	printf ("%s\n", ptr);
	return 0;
}

As you can see, I haven't allocated the space for the pointer ptr. When I 
ran the program, instead of giving me the segmentation fault, it just ran 
printing "khalid". Is it a bug of gcc or the kernel.

-- 

**************************************************************************

Mohammed Khalid Ansari                    Tel (res) : 0091-022-3051360
Assistant Manager II                          (off) : 0091-022-2024641
National Centre for Software Technology   Fax       : 0091-022-2049573 
8th flr,Air India Build. Nariman Point,   E-Mail    : khalid@ncst.ernet.in 	
Mumbai 400021.

Homepage : http://soochak.ncst.ernet.in/~khalid			  	  

**************************************************************************


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-06-08 17:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-08 10:33 is it a buf or what? Mohammed Khalid Ansari
2002-06-08 12:03 ` Glynn Clements
2002-06-08 16:40 ` Elias Athanasopoulos
2002-06-08 17:24 ` Marius Nita

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).