counting length of string token using istringstream

166 Views Asked by At

I'm getting an error saying no matching function for call to 'getline' involving the getline(tokenizer, " "); Im not sure how to fix this, Ive tried including some other headers but I just keep coming up with more errors.

#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <string>


using namespace std;

char encrypt(char character, int offset);

int main(int argc, char *argv[]) {

ifstream inputFile;
string str;
string token;
bool debug = true;
int lineLength = 0, offset;

inputFile.open(argv[1]);
if (inputFile.fail())
    cout << "File failed to open. \n";

istringstream tokenizer(str);
getline(tokenizer, " ");
offset = token.length();

while (getline(inputFile, str)){
    lineLength = str.length();

    for (int i = 0; i < lineLength; i++)
        str.at(i) = encrypt(str.at(i), offset);

    cout << str << endl;
}

inputFile.close();
return(0);
}
0

There are 0 best solutions below