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 do mean by network ?
Is c high or low level?
Can you return null in c?
What are the properties of union in c?
What is structure padding in c?
How can I do serial ("comm") port I/O?
Can static variables be declared in a header file?
What is the equivalent code of the following statement in WHILE LOOP format?
How to write a code for reverse of string without using string functions?
What is wrong with this program statement?
What should malloc(0) do?
What are the types of functions in c?
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
What is meant by type casting?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,