no matching function for call to getline

//******************** main.cpp ************************

#include <iostream>

bool loop();

int main() {

loop();

return 0;

}

bool loop()

{

while(1) {

char user_answer[0x1000];
std::getline (user_answer, 0x1000);

std::cout << "type quit " << std::endl;

if (!std::strcmp(user_answer,"quit"))

{

break;

}

}

return 0;

}

//******************** end of main.cpp ************************

I get: no matching function for call to `getline(char[4096], int)'

I am trying to read in the command 'quit' from the console, at which
point the program exits.

I'm not putting this in main because I plan to add much more 'stuff' to this function.

Thank you for your time.



Either you use std::string for getline (std::getline(std::cin, str)) or this std::cin.getline(user_answer, 0x1000);
getline is only one function.not one object.
you should use std::cin>>user_answer; or std::cin.getline (user_answer, 0x1000); to get a input buffer.
Thanks for your help guys it works for now, until I break it again anyways ;)
Btw, why does loop return a bool which is never used, and why does it return 0 instead of true or false?
Topic archived. No new replies allowed.