{{keywords>wiki library source code example reference}} ===== gets ===== char *gets(char *str); Copies characters from stdin into str until newline encountered, end-of-file reached, or error occurs. Does not copy newline. NUL-terminates s. Returns str, or NULL on end-of-file or error. Should not be used because of the potential for buffer overflow. ===== C Sourcecode Example ===== /* * gets example code * http://code-reference.com/c/stdio.h/gets */ #include /* including standard library */ //#include /* uncomment this for Windows */ #include /* Included for strlen */ int main( void ) { char string[80]; int i,end; printf("Please enter string (Max 80 characters):"); gets(string); end = strlen(string)-1; for (i=0; i <= end ;i++) { printf("%c",string[i]); } printf("\n"); return 0; } ==== output ==== ./gets Please enter string (Max 80 characters):Test 4 http://code-reference.com/c/stdio.h/gets Test 4 http://code-reference.com/c/stdio.h/gets