String Input Take Without any gets function just scanf is enough for taking any input withlout gets function
#include<stdio.h>
int main(){
char str[80];
printf("enter your name: ");
scanf("%[A-Za-z ]",str); //dave //here is the magic
printf("Welcome, %s\n ",str);
return 0;
}
another example:
#include<stdio.h>
int main(){
char str[80];
printf("enter your name: ");
scanf("%[^A]",str); //this is going to accept anything except the A..if A found then anything after that will not print output
printf("Welcome, %s\n ",str);
return 0;
}
another:
#include<stdio.h>
int main(){
char str[80];
printf("enter your name: ");
scanf("%[^\n]",str); //dave //this is going to accept anything except the new line
printf("Welcome, %s\n ",str);
return 0;
}
//^ this sign is a except sign