C Program to accept data from user store that data into text file

How to write a C program to accept data from user store that data into text file in C Programming Language ?


Solution:
/*write a c program to accept data from user store that data into text file */
#include<stdio.h>
#include<conio.h>
void main()
{
char str[60];
FILE *fp;
clrscr();
printf("\nenter the string:");
gets(str);
fp=fopen("peer.txt","w");
if(fp==NULL)
{
printf("connot open");
exit();
}
fputs(str,fp);
getch();
}
/*
enter the string:i am not an intelligent                                      
                                                                             
Type EXIT to return to Turbo C++. . .Microsoft(R) Windows DOS                
(C)Copyright Microsoft Corp 1990-2001.                                        
                                                                             
C:\TC\BIN>type peer.txt                                                      
i am not an intelligent                                                      
C:\TC\BIN>exit                                                                
*/


Learn More :