LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-09-2011, 04:43 PM   #1
hollyj
LQ Newbie
 
Registered: Oct 2011
Location: New Orleans
Posts: 4

Rep: Reputation: Disabled
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;

}

Last edited by hollyj; 10-09-2011 at 04:52 PM.
 
Old 10-09-2011, 04:49 PM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,254

Rep: Reputation: 314Reputation: 314Reputation: 314Reputation: 314
What this means?
Code:
cin >> "is"
And please use CODE tags around your code, and specify exact error message you get (with line number).
 
Old 10-09-2011, 04:50 PM   #3
hollyj
LQ Newbie
 
Registered: Oct 2011
Location: New Orleans
Posts: 4

Original Poster
Rep: Reputation: Disabled
Well now it doesn't return an error. It returns nothing.
 
Old 10-09-2011, 05:38 PM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by hollyj View Post
Well now it doesn't return an error. It returns nothing.
Doesn't that mean it compiled, then? You shouldn't edit your post to remove the problems you're asking about because when other people read the post they can't find evidence of the problem. You should also post complete error messages since they include the semantic information necessary to figure out where the problem is.
Kevin Barry
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
No match for 'operator<<' in '((HttpRequest* fsshl Programming 2 07-14-2011 07:07 PM
unary operator expected error! Lynda_M Programming 3 11-29-2008 12:04 PM
Unary operator error hinetvenkat Programming 7 10-26-2008 11:22 AM
build error -- can not find operator new George2 Programming 1 11-05-2007 12:10 PM
Binary operator expected - error mike9287 Linux - Newbie 9 07-17-2006 08:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration