Hyluss icon

Operacje na plikach, tablice rejestracyjne

Hyluss | PRO | 07/02/16 07:01:59 PM UTC | 0 ⭐ | 512 👁️ | Never ⏰ | []
C |

1.1 KB

|

None

|

0 👍

/

0 👎

// 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;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎