A simple program that I wrote using C programming to write a text file.
I am using Dev C++ as my C compiler in writing this program.
If you like my work please click the ads on my website to support my work. I will really appreciate your help.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
I am using Dev C++ as my C compiler in writing this program.
If you like my work please click the ads on my website to support my work. I will really appreciate your help.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
My personal website is http://www.jakerpomperada.com
Sample Program Output
Program Listing
/*open_write_read.c
Author : Mr. Jake R. Pomperada, MAED-IT
Tool : Dev C++ Version 5.11
Date : December 2, 2018 Sunday 6:30 AM
*/
/* Open, write and close a file : */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
FILE *fp ;
char data[100];
printf("\n\n");
printf("\tText File Opening, Write and Read Example in C");
printf("\n\n");
// opening an existing file
printf( "\tOpening the file write.txt in write mode" ) ;
printf("\n\n");
fp = fopen("write.txt", "w") ;
if ( fp == NULL )
{
printf( "Could not open file write.txt" ) ;
return 1;
}
printf("\tEnter some text from keyboard to write in the file write.txt" );
printf("\n\n");
/* getting input from user */
while ( strlen ( gets( data ) ) > 0 )
{
/* writing in the file */
fputs(data, fp) ;
fputs("\n", fp) ;
}
/* closing the file */
printf("\n");
printf("\tClosing the file write.txt") ;
fclose(fp);
printf("\n");
printf("\tData have been written successfully.");
printf("\n\n");
printf("\tEND OF PROGRAM");
printf("\n\n");
system("pause");
}
No comments:
Post a Comment