#include<stdio.h>
int main(){
char arr[20];
int a;
int count=0;
while(1){
printf("enter string with space:");
fflush(stdin);
scanf("%[^\n]%*c", arr);
printf("enter integer:");
scanf("%d",&a);
count++;
if(count==4){
break;
}
}
}
I want to read string with space and I have to use this code. I wrote this in while loop and I want to read string and after integer number and it does not work.
Output:
enter string with space:hey hey
enter integer:159
enter string with space:enter integer:
But output should be:
enter string with space:hey hey
enter integer:159
enter string with space:.... heyy
enter integer: 1235