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
a value that does not change during program execution a) variabe b) argument c) parameter d) none
What is volatile variable in c with example?
write a program to display all prime numbers
Do pointers need to be initialized?
What are the primitive data types in c?
What is a program flowchart?
Differentiate between static and dynamic modeling.
What is dynamic variable in c?
Which is more efficient, a switch statement or an if else chain?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
How to Throw some light on the splay trees?
What's the total generic pointer type?
Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.
Is python a c language?
What are dangling pointers in c?