Z
ziibrs
Is it true that it is not allowed to overwrite statically initialized
char * ?
For example:
#include <stdio.h>
#include <string.h>
int main(void)
{
char *dest=" ";
char *src="kakjis";
memcpy(dest,src,1);
printf("%s",dest);
return 0;
}
the gived code compiled with gcc under SuSe 10.1 gives segmentation
fault;
if i replace char *dest=" "; with a correct malloc everything
works.
Could someone please explain this behaivor to me ?
char * ?
For example:
#include <stdio.h>
#include <string.h>
int main(void)
{
char *dest=" ";
char *src="kakjis";
memcpy(dest,src,1);
printf("%s",dest);
return 0;
}
the gived code compiled with gcc under SuSe 10.1 gives segmentation
fault;
if i replace char *dest=" "; with a correct malloc everything
works.
Could someone please explain this behaivor to me ?