Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- FILE *tied;
- struct henkilotiedot
- {
- char etunimi[20];
- char sukunimi[20];
- char puh_nro[20];
- } ;
- struct henkilotiedot henkilo[50];
- int i;
- int maara;
- tied=fopen("luettelo.txt","r");
- fscanf(tied,"%d",&maara);
- for(i=0; i<=maara; i++){
- fscanf(tied, "%s %s %d", &henkilo[i].etunimi[0], &henkilo[i].sukunimi[0], &henkilo[i].puh_nro[0]);
- }
- fclose(tied);
- for(i=0; i<=maara; i++){
- printf("%s %s %d\n", henkilo[i].etunimi, henkilo[i].sukunimi, henkilo[i].puh_nro);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment