Program to write some contents into a file using file
operations with proper error messages.
Answers were Sorted based on User's Feedback
Answer / manvitha
//writing into a file
main()
{
char c;
FILE *fp;
fp=fopen("infor.dat",'w');
printf("enter data \n enter tab & enter a stop\n");
do
{
c=getchar();
put c(c,fp);
}while(c!='\t');
fclose(fp);
getch();
}
| Is This Answer Correct ? | 6 Yes | 2 No |
Answer / 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 |
difference between string and array?
what is unsigened char and what is the difference from char
When should volatile modifier be used?
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
What is C++
What are header files why are they important?
What is #define?
what is the difference between getch() and getche()?
how to swap 4 number without using temporary number?
what will be the output for the following program? main() { char ch = 'k'; char c; printf("%c",c); }
What is string in c language?
what is a constant pointer in C