Program to write some contents into a file using file
operations with proper error messages.

Answers were Sorted based on User's Feedback



Program to write some contents into a file using file operations with proper error messages...

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

Program to write some contents into a file using file operations with proper error messages...

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

Post New Answer

More C Interview Questions

hi , please send me NIC written test papers to sbabavalli@gmail.com

0 Answers   NIC,


What are the header files used in c language?

0 Answers  


Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)

2 Answers  


what is volatile in c language?

9 Answers   Cap Gemini, HCL, Honeywell, TCS, Tech Mahindra,


what are two kinds of java

2 Answers  






What is the equivalent code of the following statement in WHILE LOOP format?

0 Answers  


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

0 Answers  


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?

0 Answers  


How can I invoke another program or command and trap its output?

0 Answers  


what is used instead of pointers in java than c?

1 Answers   Vuram,


Explain enumerated types in c language?

0 Answers  


Categories