gets vs scanf for str

 #include <stdio.h>


int main() {

    // Write C code here

    char str[34];

    printf(" Enter your name : ");

    gets(str);

    

    printf("You name is  %s",str);

    

}

//YOU WILL GET MULTI-STRINGS .IE , SPACES BETWEEN NAMES TOO


//*****************


#include <stdio.h>


int main() {

    // Write C code here

    char str[34];

    printf(" Enter your name : ");

    scanf("%s",str);

    

    printf("You name is  %s",str);

    

}

//ONLY PRINTS 1ST NAME

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings