Program to write some contents into a file using file
operations with proper error messages.
Answer Posted / 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 View All Answers
What is the value of c?
Are negative numbers true in c?
What is the method to save data in stack data structure type?
I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.
What is a spanning Tree?
What is volatile variable in c?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
can any one tel me wt is the question pattern for NIC exam
Explain heap and queue.
What does static variable mean in c?
If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402
What is difference between union and structure in c?
What are data structures in c and how to use them?
Explain what are bus errors, memory faults, and core dumps?
Why do we use stdio h and conio h?