0

I have written this code and it throws back this error,

#include <iostream>
#include <string>
int main(){
    int bal=100;
    std::cout<<"Current balance: "<<bal<<std::endl;
    std::cout<<"Enter amount to withdraw: ";
    int wdamt = 0;
    std::cin>>wdamt;
    std::cout<<std::endl;
    std::string wdnote;
    std::cout<<"Enter Note: ";
    std::getline(std::cin, wdnote);
    std::cout<<"Amount: "<<wdamt<<std::endl;
    std::cout<<"Note: "<<wdnote<<std::endl;
    std::cout<<"Confirm? (Y/N): ";
    std::string conf;
    std::cin>>conf;
    if (conf == "Y"||conf == "y")
    {
        //*add to the transaction log*//
    }
    else
    {
        std::cout<<"Invalid choice.";
    }
    return 0;
}

The error

no matching function for call to 'std::basic_istream::getline(std::istream&, std::string&)' gcc [ln 10, Col 28]

I was expecting the code to ask user for a string input and store it in "wdnote" but the programs skips the asking for input part and runs the next line of code.

Output: It skips the input part and directly runs the next line of code

Arnav
  • 3
  • 1
  • 2

0 Answers0