/* C Program to read data from keyword and store into a file abc.txt */ By Amit raj purohit
http://codevidyalay.blogspot.com
#include<stdio.h>
int main()
{
FILE *fp;
char ch;
fp=fopen("abc.txt","w");
if(fp==NULL)
{
printf("File opening error...");
return 0;
}
printf("Enter your data:\n");
while((ch=getchar())!=EOF)
{
fputc(ch,fp);
}
printf("Data stored sucessfully...");
fclose(fp);
return 0;
}
INPUT/OUTPUT:
Enter your data:
this is a sample file
^Z
Data stored sucessfully...
Content of abc.txt file:
this is a sample file
Related Posts:
Perfect Number in C
Perfect Number in C
Here you will get program for perfect number in C.
Perfect number is a positive number which is equal to the sum of all its divisors excluding itself.
For example:
28 is a perfect number as… Read More
/* C Program to find the sum of individual digits of given no. */
/* C Program to find the sum of individual digits of given number*/
#include<stdio.h>
int main()
{
int n,r,sum=0;
printf("Enter a no:");
scanf("%d",&n);
while(n>0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
print… Read More
Armstrong Number in C
Armstrong Number in C
Before going to write the c program to check whether the number is Armstrong or not, let's understand what is Armstrong number.
Armstrong number is a number that is equal to the sum of cub… Read More
Triangle pattern program in C
/* C Program to print the following triangle pattern for given n*/ By Amit raj purohit
#include<stdio.h>
int main()
{
int i,j,n;
printf("Enter a no:");
scan… Read More
Fibonacci Series in C
Fibonacci Series in C
Fibonacci Series in C: In case of fibonacci series, next number is the sum of previous two numbers for example 0, 1, 1, 2, 3, 5, 8, 13, 21 etc. The first two numbers of fib… Read More