Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

get an education you leet hax0rs

Name: Anonymous 2006-03-20 20:42

"Computer Science is no more about computers than Astronomy is about telescopes" - Dijkstra

Name: Anonymous 2006-03-29 1:44

>>28
You forgot to check if malloc returned NULL. And strcpy is insecure.

#define BUFSIZE 200
char *s; /*Create string*/
s = malloc(BUFSIZE); /*Fixed-length string*/
if(s == NULL) /*Check if malloc failed*/
  abort(); /*terminate in this case*/
memset(s, '\0', BUFSIZE - 1); /*Blank string*/
s[BUFSIZE - 1] = 0; /*Final zero*/
strncpy(s, "Hello world!", BUFSIZE - 1); /*Put message on string*/
printf("%s\n", s); /*Print message on screen*/

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List