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


Please Help Members By Posting Answers For Below Questions

What is 1f in c?

1833


What will the preprocessor do for a program?

584


Explain the difference between structs and unions in c?

572


Why C language is a procedural language?

614


How can you restore a redirected standard stream?

606






Is this program statement valid? INT = 10.50;

686


Are there any problems with performing mathematical operations on different variable types?

569


How will you declare an array of three function pointers where each function receives two ints and returns a float?

773


What does #pragma once mean?

682


write a program fibonacci series and palindrome program in c

630


What is static memory allocation? Explain

627


Explain two-dimensional array.

623


When the macros gets expanded?

780


How can you increase the size of a dynamically allocated array?

639


a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler

609