lundi 26 octobre 2015

If/Else when spacebar is pressed (C)

This C program has to print user's surname and I want to introduce the case of double surnames using IF/Else. The condition I thought to use is: "when spacebar is pressed, collect another string". The matter is that I don't know how to define this condition..

this is my code:

    printfcognome() {
char cognome[DIM];
char cognome2[DIM];

printf("Inserisci il tuo cognome\n");
scanf("%s", cognome);

    if(???) {
    scanf("%s", cognome2);
    printf("Il tuo cognome è " "%s %s", cognome, cognome2);
    }   else    {
    printf("Il tuo cognome è " "%s", cognome);
    }

}

Aucun commentaire:

Enregistrer un commentaire