#include int main(void){ FILE *f; int m[]={10, 20, 30, 40, 50}; int nr; f=fopen("temp.dat", "wb"); if(!f){ printf("kirjutusprobleem\n"); return 1; } printf("asukoht peale avamist: %ld\n", ftell(f)); //long decimal fwrite(m, sizeof(int), 5, f); printf("peale kirjutamist: %ld\n", ftell(f)); if(fclose(f)){printf("Probleem sulgemisel\n");} f=fopen("temp.dat", "rb+"); printf("peale avamist: %ld\n", ftell(f)); fread(&nr, sizeof(int), 1, f); printf("arv %d, nihe %ld\n", nr, ftell(f)); fread(m, sizeof(int), 2, f); printf("m[1]=%d: , fail: %ld\n", m[1], ftell(f)); rewind(f); printf("Algusse liikudes: %ld\n", ftell(f)); fread(m, sizeof(int), 5, f); printf("m[1]=%d: , fail: %ld\n", m[1], ftell(f)); fseek(f, 2*sizeof(int), SEEK_SET); //SEEK_SET - faili algusest printf("Kohal 2: %ld\n", ftell(f)); fread(&nr, sizeof(int), 1, f); printf("arv %d, nihe %ld\n", nr, ftell(f)); nr=13; fwrite(&nr, sizeof(int), 1, f); fclose(f); return 0; }