I'm writing a code and I need to be able to input 2 int values and a line of numbers with spaces inbetween so I wrote:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int main()
{
int L, X;
char lin[25] = {};
scanf("%d", &L);
scanf("%s", &lin);
scanf("%d", &X);
return 0;
}
In console I input the first number(L) and that works but when the second scanf for the string is supposed to happen it just skips it(as seen in the debugger) and assigns the first number I wrote in the line to the X variable. Also locals tab shows first line of string lin is usually '\n' and I dont think its from my keyboard sending double the amount of signals when I press that key. I tried using fgets(lin, 25, stdin) but it does the same thing.
Does anyone have an idea how to take input of int, string (of numbers and spaces for characters) and the int in that order?
I tired to take input of int, string (of numbers and spaces for characters) and the int in that order