Subject: snprintf() problem or I am stupid C programmer
To: 'current-users@netbsd.org' <current-users@netbsd.org>
From: Ciarcinski, Adam \(ISS Brussels\) <ACiarcinski@iss.net>
List: current-users
Date: 07/17/2001 11:51:52
Hello,

First of all, sorry for putting it on this list, but I'm using NetBSD.
I have problem with the following, simple, piece of C code:


#include <stdio.h>

int main()
{
char *test = "Test";

printf("%s\n", test);
snprintf(test, 5, "Passed");
printf("%s\n", test);

return 0;
}


If you compile and run it - crash!
If you change 'char *test' to 'char test[]' - works!

Tried with egcs-1.1.2 and gcc-2.95.3 on NetBSD-current (yesterday sources).

Please help.  Thank you. :)

	kind regards

		- Adam