// operacje na plikach // talbicerejestracyjne.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include #include #define _CRT_SECURE_NO_DEPRECATE struct structRejestracja { char woj[20]; char miasto[20]; }; int _tmain(int argc, _TCHAR* argv[]) { structRejestracja Rejestr [100]; int i=0; int wynik; FILE *wczytaj; FILE *zapisz; wczytaj = fopen ("wrejestracja.txt","r"); if (wczytaj == NULL) { perror ("blad"); exit (1); } while (!feof (wczytaj)) { fscanf (wczytaj,"%s %s",&Rejestr[i].woj,&Rejestr[i].miasto); printf ("%s %s\n",Rejestr[i].woj, Rejestr[i].miasto ); wynik = strcmp ( "SY" , Rejestr[i].woj); if (0 == wynik) { i++ ; } } zapisz = fopen ("zrejestracja.txt","w"); if (zapisz == NULL) { perror ("blad"); fclose (wczytaj); exit (1); } for (int j=0; j