error: no match for operator
Hey guys! I'm an extremely new c++ programmer. Can you offer suggestions on why I get the "no match for operator" error with the following code? I think it may be that my text file is too big for a string.
#include<iostream> #include<string> #include<vector> #include<cmath> #include<fstream> #include<stdlib.h> using namespace std; int main(){ string line; ifstream text( "text.txt" ); getline( text, line ); text.close(); //for( int i = 0; i < line.length(); i++ ){ // cout << line[ i ] << " "; //} cout << endl; string P = "is"; long long int PRIME = atoll("10002949999"); int l_line = line.length(), l_P = P.length(), t=0, h = 1, d = 26, H = 0; for (int i=1; i < l_P; i++) h = (h * d) % PRIME; for (int i=0;i<l_P;i++) { H = ( (d*H) + P[i] - 'a')%PRIME ; t = ( (d*t) + line[i] - 'a')%PRIME ; } for (int i = 0, j = l_line - l_P - 1 ; i < j ; i++){ if (t == H){ int state = 1; for (int k = 0 ;k < l_P; k++) if (line[i+k] != P[k]){ state = -1; break; } if (state == 1 ){ cout << " Match found at index : " << i << "\n"; } } else{ t = ( (d * (t - h*(line[i]-'a')) + line[i+l_P] - 'a')%PRIME ); } } return 0; } |
What this means?
Code:
cin >> "is" |
Well now it doesn't return an error. It returns nothing.
|
Quote:
Kevin Barry |
All times are GMT -5. The time now is 04:34 PM. |