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

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