I am new to C programming and i cant understand why can't I take a string input as the cursor is skipping taking input like in scanner class in java. Please help. It's Compiling successfully but while execution the input line is getting skipped. I'm attaching my code here:
#include<stdio.h>
#include<string.h>
int main()
{
int n;
char ch[1000];
int end=0;
while(1)
{
printf("1. Reading a string\n"
"2. Display the string\n"
"3. Merge two strings\n"
"4. Copy n characters from mth position\n"
"5. Calculate the length\n"
"6. Count the no. of words, lines and characters\n"
"7. Replace with 'hello'.\n"
"Any other number to exit\n");
scanf("%d", &n);
switch(n){
case 1:
{
printf("Enter the string\n");
gets(ch);//have already tried fgets and scanf also but no luck.
break;
}
...