using codeblocks
----------------------------------------------------------------------------------
//using getc() to read (one character)that data from an opened
#include <stdio.h>
int main()
{
FILE *p; //pointer declaration
char ch;
printf("now we are going to read that stored data\n");
p=fopen("data.txt","r"); // openes the file in read only mode. We should know the file name.
while((ch=getc(p))!=EOF) //read a character using getc from opened file.
{
putchar(ch); //prints that character on screen
}
fclose(p); //closes the file
return 0;
}
-------------------------------------------------------------------------------------------
using turboc++
-----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------
//using getc() to read (one character)that data from an opened
#include <stdio.h>
int main()
{
FILE *p; //pointer declaration
char ch;
printf("now we are going to read that stored data\n");
p=fopen("data.txt","r"); // openes the file in read only mode. We should know the file name.
while((ch=getc(p))!=EOF) //read a character using getc from opened file.
{
putchar(ch); //prints that character on screen
}
fclose(p); //closes the file
return 0;
}
-------------------------------------------------------------------------------------------
using turboc++
-----------------------------------------------------------------------------------------------------------
//using getc() to read (one character)that data from an opened
#include <stdio.h>
#include<conio.h>
int main()
{
FILE *p; //pointer declaration
char ch;
printf("now we are going to read that stored data\n");
p=fopen("data.txt","r"); // openes the file in read only mode. We should know the file name.
while((ch=getc(p))!=EOF) //read a character using getc from opened file.
{
putchar(ch); //prints that character on screen
}
fclose(p); //closes the file
getch();
return 0;
}
#include <stdio.h>
#include<conio.h>
int main()
{
FILE *p; //pointer declaration
char ch;
printf("now we are going to read that stored data\n");
p=fopen("data.txt","r"); // openes the file in read only mode. We should know the file name.
while((ch=getc(p))!=EOF) //read a character using getc from opened file.
{
putchar(ch); //prints that character on screen
}
fclose(p); //closes the file
getch();
return 0;
}
No comments:
Post a Comment