Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // operacje na plikach
- // talbicerejestracyjne.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #include <stdlib.h>
- #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<i;j++) {
- fprintf (zapisz,"%s %s \n",Rejestr[j].woj, Rejestr[j].miasto);
- printf ("%s %s \n",Rejestr[j].woj, Rejestr[j].miasto);
- }
- _getch();
- return 0;
- }
Advertisement