Mega Code Archive
Categories
/
C
/
Code Snippets
Add null terminator to string end
#include
int main(void) { char s[256], *j; j = s; while((*j++ = getchar())!= '\n') ; *j = '\0'; /* add null terminator */ printf(s); return 0; }