Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "header.h"
- void LeggiVettore(studente st[],int*n){
- int i;
- int m=0;
- puts("\nInserire quanti elementi si vogliono inserire: ");
- scanf("%d" ,&m);
- getchar();
- printf("\nInserire %d studenti: \n",m);
- for(i=0;i<m;i++){
- printf("\nInserire studente %d" ,i+1);
- puts("\nInserire cognome e nome: ");
- gets(st[i].Nominativo);
- puts("\nInserire Data di nascita: ");
- scanf("%d" ,&st[i].dataN.anno);
- puts("\nInserire Mese: ");
- scanf("%d" ,&st[i].dataN.mese);
- puts("\nInserire Anno: ");
- scanf("%d" ,&st[i].dataN.anno);
- puts("\nInserire sesso: ");
- scanf("%s" ,&st[i].sesso);
- puts("\n");
- getchar();
- }
- *n=m;
- }
- void SalvaSuFile(FILE*out,studente st[],int n){
- int i;
- if(out==NULL) printf("\nIl file non può essere aperto!");
- else{
- for(i=0;i<n;i++){
- fprintf(out,"Studente: %s\nData di nascita:%d/%d/%d\nSesso: %s\n\n",st[i].Nominativo,st[i].dataN.giorno,st[i].dataN.mese,st[i].dataN.anno,st[i].sesso);
- }
- ("\nL'elenco e' stato salvato correttamente sul file!");
- }
- }
- void StampaDaVettore(studente st[],int n){
- int i;
- for(i=0;i<n;i++){
- printf("\nStudente %d" ,i+1);
- printf("\nCognome e Nome: %s" ,st[i].Nominativo);
- printf("\nData di nascita: %d/%d/%d ",st[i].dataN.giorno,st[i].dataN.mese,st[i].dataN.anno);
- printf("\nSesso: %s" ,st[i].sesso);
- puts("\n");
- }
- }
- void StampaDaFile(FILE*out){
- char c;
- if(out==NULL) printf("\nIl file non può essere aperto!");
- else{
- puts("\n\nSTAMPA DA FILE\n");
- fgetc(out);
- while(!feof(out)){
- putchar(c);
- fgetc(out);
- }
- }
- fclose(out);
- }
- int RicercaPrimo(studente st[],int n){
- int i;
- int position=0;
- while(i<n){
- if(strcmp(st[i].Nominativo,st[i+1].Nominativo)>0){
- position=i+1;
- }
- i++;
- }
- return position;
- }
- void StampaPrimo(studente st[],int n,int primo){
- printf("\nIl primo nominativo in ordine alfabetico e': %s",st[primo].Nominativo);
- printf("\nLa posizione e': %d" ,primo);
- }
Add Comment
Please, Sign In to add comment