Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<stdio.h>
- int main(){
- FILE *fp;
- int value = 0, rel = 0;
- //create new file with write mode
- fp = fopen("one.txt","w");
- printf("\n Enter the value to write: ");
- scanf("%d",&value);
- //writing value to file
- //putw(value, fp);
- fprintf(fp, "%d", value);
- //closing file from write mode
- fclose(fp);
- //opening file with read mode
- fp = fopen("one.txt","r");
- //reading value from file
- //rel = getw(fp);
- fscanf(fp, "%d", &value);
- printf("\n The result is:%d\n", value);
- //closing file from write mode
- fclose(fp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement