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

write a program to arrange the contents of a 1D array in ascending order

4 Answers  


What is meant by keywords in c?

0 Answers  


What does 3 mean in texting?

0 Answers  


Hai friends im a i year student. i want to develop my knowledge in the field of TSR in c. How I'm Improve ?

2 Answers  


Difference between malloc() and calloc() function?

0 Answers  


Reverse the part of the number which is present from position i to j. Print the new number. eg: num=789876 i=2 j=5 778986

1 Answers  


What does d mean?

0 Answers  


write a prgram of swapping with 2 valiables

6 Answers  


What is difference between Structure and Unions?

0 Answers   TISL,


what is difference between array,strutter,union and pointers

3 Answers   CTS, Lovely Professional University, Mannar Company,


What is array in C

0 Answers  


#include<conio.h> #include<stdio.h> void main() { int i; if(1,0,2,3) { printf("if"); } else { printf("else"); } getch(); } Can any body tell the answer of this question with explanation?

3 Answers   Huawei,


Categories