Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(toiminto == 1){
- printf("Anna etunimi: ");
- scanf("%s", &etunimi[0]);
- printf("Anna sukunimi: ");
- scanf("%s", &sukunimi[0]);
- printf("Anna ikä: ");
- scanf("%d", &ika);
- printf("Anna paino: ");
- scanf("%f", &paino);
- henkilo_tiedot = fopen("Data.txt", "a");
- fprintf(henkilo_tiedot, "%s %s %d %.1f\n", etunimi, sukunimi, ika, paino);
- fclose(henkilo_tiedot);
- }
- if(toiminto == 2){
- henkilo_tiedot = fopen("Data.txt", "r");
- while(feof(henkilo_tiedot) == 0){
- fscanf(henkilo_tiedot, "%s %s %d %f\n", &etunimi[0], &sukunimi[0], &ika, &paino);
- printf("%s %s, %d vuotta ja %.1f kg.\n", etunimi, sukunimi, ika, paino);
- }
- fclose(henkilo_tiedot);
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment