/* The below program receives strings from keyboard and writes them to file */ #include <stdio.h> #include <conio.h> #include <stdlib.h> void main( ) { FILE *p ; char string[80] ; p = fopen ( "check.txt", "w" ) ; if ( p == NULL ) { puts ( "Unable to open file" ) ; exit(1) ; } printf ( "\nEnter text :\n" ) ; while ( strlen ( gets ( string ) ) > 0 ) { fputs ( string, p ) ; fputs ( "\n", p ) ; } fclose ( p ) ; getch(); }
int mLen = 0; char* strInput = gets ( string ); // console blocks here waiting for input mLen = strlen(strInput); while ( mLen > 0 ) { fputs ( string, p ) ; fputs ( "\n", p ) ; strInput = gets ( string ); // console blocks here waiting for input mLen = strlen(strInput); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)