Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <stdio.h>
- #include <iostream>
- using namespace std;
- /*
- Zapisać dane z tablicy liczb do pliku a następnie wczytać dane z pliku od jego końca.
- */
- int main()
- {
- FILE *file;
- file = fopen ("3.txt","w");
- int tab[] = {1,2,3,4,5,6,7,8};
- int size = sizeof(tab)/sizeof(int);
- int i=0;
- while(i<size)
- {
- fprintf (file, "%i",tab[i]);
- i++;
- }
- fclose(file);
- file = fopen ("3.txt","a+");
- fseek(file,0,2);
- char c;
- for(int i=1;i<size+2;i++)
- {
- c=fgetc(file);
- cout << c;
- fseek(file,-i,2);
- }
- fclose(file);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment