Category : getline

It didn’t take the input correctly using getline(cin,s).It takes 1st input as empty space.can anyone please solve this for example code is #include<bits/stdc++.h> #include<string> using namespace std; int main() { int t; cin>>t; for(int i=0;i<t;i++) { string s; getline(cin,s); cout<<s<<endl; } } if input is: 5 In keyboard the keys are arrange in the order ..

Read more

I’m storing Port and IP addresses in a text file "info.txt" info.txt: 36451 192.184.255.255 48703 192.184.255.255 Pseudo code: errmsg.Clear(); ifstream fp(mLockFile.Str()); if (!fp.is_open()) { errmsg << "Could not open file " << mLockFile.Str(); return retval; } UInt16 port = 0; char ipaddr[1024]; char read[1024]; fp.getline(read, 1023); TLOG1("mLockFile fp read:%s",read); //I have added if(fp.getline(read, 1023)) { ..

Read more

Hello there i am a beginner in c++ and need your help, can someone answer me why ich coudln’t use getline in my function. It always show me " no matching function to call ‘getline’ ". #include "Timer.h" #include "p4.h" #include <algorithm> #include <iostream> #include <random> #include <vector> bool isPalindrome(const string& p){ cout << "Please ..

Read more