Mega Code Archive

 
Categories / C / Code Snippets
 

Get string from console and output it

#include <stdio.h> int main(void) { char str[100]; printf("Enter a string: "); if(gets(str)) /* if not null */ printf("this is your string: %s", str); return 0; }