|
|
> On Tue, 29 Apr 2008 18:34:16 -0700, Barry Schwarz wrote:
>> On Tue, 29 Apr 2008 15:47:30 +0500, arnuld <NoSpam@xxxxxxxxxx> wrote:
>> char *buffer = 0;
>> char *buffer2 = NULL;
>>
>> printf("%s\n%s\n", buffer, buffer2);
> Obviously you wanted to do something else rather than invoke undefined
> behavior here. Did you mean to use %p instead of %s? If so, it would
> be a good to acquire the habit of casting the pointers to void* (even
> though a char* would work without the cast).
I really meant %s because I am providing printf an array, whether empty or
full and you do see that its prints without any problem:
/home/arnuld/programs/C $ gcc -ansi -pedantic -Wall -Wextra test.c
/home/arnuld/programs/C $ ./a.out
(null)
(null)
/home/arnuld/programs/C $
BTW, I used %d, %lu, %s but what is %p ?
--
http://lispmachine.wordpress.com/
my email ID is at the above address
|
|