Mega Code Archive

 
Categories / C / String
 

Add null terminator to string end

#include <stdio.h> int main(void) {   char s[256], *p;   p = s;   while((*p++ = getchar())!= '\n') ;   *p = '\0'; /* add null terminator */   printf(s);   return 0; }