Q.1)Write a program to display user details as User name,Email,Contact no,Address each on new line.
#include<stdio.h>
#include<conio.h>
void main(){
char username[25],Email[40],contact[15],add[80];
clrscr();//to be used after
printf("Enter all your details below\n");
*//gets() function does not work after the scanf() function.
//i.e gets() should be written on top after declaration to work.*
printf("username :");
scanf("%s",&username[0]);
printf("Enter your Address:");
gets(add); // **←---------------------------------------GETS( ) inserted after scanf()**
printf("Email ID :");
scanf("%s",Email);
printf("Contact :");
scanf("%s",contact);
printf("\nYour username is %s\n",username);
printf("Your Email ID is %s\n",Email);
printf("Your Contact No. is %s\n",contact);
printf("Your Address is %s\n",add);
getch();
}
gets() function is not taking any input from the user; once it is used after scanf() function.
1.I don't know why gets function is behaving in this manner?? 2.Same happens with scanf("%c")[format specifier for char] when its is used after scanf("%s")[format specifier of string]