0

Here is the code, I use Codeblocks, miwGW compiler

#include <iostream>
#include <string.h>
using namespace std;

int main()
{
int L; char sir[100];
cin>>L;
cin.getline(sir,100);
    return 0;
}

After reading the L value , the execution just stop and I can't read anymore the char variable, "sir". Why ?

1 Answers1

1

Use

#include <limits>

//...

std::cin>>L;

std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );

//...
Vlad from Moscow
  • 224,104
  • 15
  • 141
  • 268