0

I want to understand how to read a getline string and ignore any white spaces, new lines, or tabs using bool functions. They will then only calls a function when the input is a double or a specific char such as "+, -, *, /"

#include<iostream>
//#include"inter.h"  // You may disregard any functions that would come from inter.h
#include<string>
using namespace std;

bool is_num(string input);
bool is_space(string input);
bool is_oper(string input);



int main(){

  string input;

  getline(cin,input);
  while (cin >> input); // read input until user enters ctrl d

  if(input.is_num(input == true) {
      // calls a push function from inter.h
      }
      else if(input.is_space == true){
      // ignores any white spaces, tabs or new line and continues to read input
      }
      else if (input.is_oper == true){
      //calls my pop function from inter.h
      }


}

bool is_num(string input){
// No idea what would go here
  return true;
}
bool is_space(string input){
// No idea what would go here needs to ignore any white space or endl;
  return true;
}
bool is_oper(string input){
// No idea what would go here
  return true;
}
  • Well, if you want to understand how to do that, read the documentation for `std::istream`, and a good C++ book. After spending some time studying, you should be able to understand how to do that very well. – Sam Varshavchik Oct 16 '16 at 00:08
  • If you want to parse the contents of a string, `getline` is irrelevant. And it's unclear what you want these functions to do. Could you give some examples? – Beta Oct 16 '16 at 00:10

0 Answers0