PPS Practical 59
- Aim: Write a program to write a string in file
- Code:
//For turbo C++ remove below comments #include <stdio.h> //#include<conio.h> void main() { // clrscr(); FILE *f; char a; printf("Enter string : \n"); f=fopen("test.txt", "w"); while ((a=getchar())!=EOF){ putc(a,f); } fclose(f); f=fopen("test.txt","r"); printf("\nFile Content: \n"); while ((a=getc(f))!=EOF){ printf("%c",a); } // getch(); }
- Output:
Comments
Post a Comment