Guest User

Untitled

a guest
Apr 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3.  
  4. FILE *tied;
  5. struct henkilotiedot
  6. {
  7. char etunimi[20];
  8. char sukunimi[20];
  9. char puh_nro[20];
  10. } ;
  11. struct henkilotiedot henkilo[50];
  12.  
  13. int i;
  14. int maara;
  15. tied=fopen("luettelo.txt","r");
  16. fscanf(tied,"%d",&maara);
  17. for(i=0; i<=maara; i++){
  18. fscanf(tied, "%s %s %d", &henkilo[i].etunimi[0], &henkilo[i].sukunimi[0], &henkilo[i].puh_nro[0]);
  19. }
  20. fclose(tied);
  21.  
  22. for(i=0; i<=maara; i++){
  23. printf("%s %s %d\n", henkilo[i].etunimi, henkilo[i].sukunimi, henkilo[i].puh_nro);
  24. }
  25. return 0;
  26. }
Add Comment
Please, Sign In to add comment