Program to write some contents into a file using file
operations with proper error messages.
Answers were Sorted based on User's Feedback
Answer / manvitha
//writing into a file
main()
{
char c;
FILE *fp;
fp=fopen("infor.dat",'w');
printf("enter data \n enter tab & enter a stop\n");
do
{
c=getchar();
put c(c,fp);
}while(c!='\t');
fclose(fp);
getch();
}
Is This Answer Correct ? | 6 Yes | 2 No |
Answer / vignesh1988i
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *pointer;
char character;
pointer=fopen("hello.c","w"); /*there must be a file in your
path*/
if(pointer==NULL)
printf("CANT OPEN THE FILE ,ITS NOT PRESENT IN THE DIRECTORY");
else
{
fflush(stdin); /*a fun() used to clear the buffer memory*/
while(1)
{
scanf("%c",&ch);
fprintf(pointer,"%c",ch);
if(ch=='$')
break;
}
}
fclose(pointer);
getch();
}
Is This Answer Correct ? | 4 Yes | 4 No |
hi , please send me NIC written test papers to sbabavalli@gmail.com
What are the header files used in c language?
Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)
what is volatile in c language?
9 Answers Cap Gemini, HCL, Honeywell, TCS, Tech Mahindra,
what are two kinds of java
What is the equivalent code of the following statement in WHILE LOOP format?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
write a program to find the number of even integers and odd integers in a given array in c language
13 Answers IAI Cameroun, NIIT, Olive Tech, QIS,
Where register variables are stored in c?
How can I invoke another program or command and trap its output?
what is used instead of pointers in java than c?
Explain enumerated types in c language?