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 in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

0 Answers  


hi, which software companys will take,if d candidate's % is jst 55%?

0 Answers  


Write a program which take a integer from user and tell whether the given variable is squar of some number or not. eg: is this number is 1,4,9,16... or not

9 Answers   Alcatel,


what is diognisis?

1 Answers  


Describe the steps to insert data into a singly linked list.

0 Answers  






exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above

0 Answers  


What is use of integral promotions in c?

0 Answers  


what is the difference between global variable & static variable declared out side all the function in the file.

2 Answers  


What is indirection in c?

0 Answers  


what is the different bitween abap and abap-hr?

0 Answers   TCS,


Is main is a keyword in c?

0 Answers  


what is pointer ?

10 Answers   Kernex Micro Systems,


Categories