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 1f in c?
What will the preprocessor do for a program?
Explain the difference between structs and unions in c?
Why C language is a procedural language?
How can you restore a redirected standard stream?
Is this program statement valid? INT = 10.50;
Are there any problems with performing mathematical operations on different variable types?
How will you declare an array of three function pointers where each function receives two ints and returns a float?
What does #pragma once mean?
write a program fibonacci series and palindrome program in c
What is static memory allocation? Explain
Explain two-dimensional array.
When the macros gets expanded?
How can you increase the size of a dynamically allocated array?
a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler