Untitled

mail@pastecode.io avatar
unknown
c_cpp
a month ago
414 B
1
Indexable
Never
// Online C compiler to run C program online
#include <stdio.h>

int main() {
    char stringa[11]; //10 caraterri + '\0'
    int i=0;
    char c;
    
    printf("Inserisci una stringa (max 10 caratteri): ");
    
    while(i<10 && scanf("%c", &c) == 1 && c != '\n' && c != EOF){
        stringa[i] = c;
        i++;
    }
    
    stringa[i]='\0';
    
    printf("Hai inserito: %s\n", stringa);

    return 0;
}
Leave a Comment