For instance if in this code i don't use getchar(), a compilation error shwos up. Please explain the reason?
    #include <iostream>
 #include <iomanip>
 #include <limits>
 
 using namespace std;
 
 int main() {
     int i = 4;
     double d = 4.0;
     string s = "HackerRank ";
     int a;
     double b;
     char c[50];
     cin>>a;
     cin>>b;
     getchar();
     gets(c);
     cout<<a+i<<"\n";
     cout<<setprecision(1)<<fixed<<d+b<<"\n";
     cout<<s+c;
     return 0; }
 
    