Can't Find Error URGENT!!!!
Jan 27, 2010 at 4:24pm UTC
I m able to read my HTML file but correct results are not being produced, can someone help run my program for me?Its very important & urgent that my program work. I would be really grateful if someone helped me identify & provide the correct results for my program.It compiles but results r wrong.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cstdlib>
#include "indexDetails.h"
using namespace std;
int main(int argc, char *argv[])
{
IndexDetails temp;
temp.readFile();
system("PAUSE" );
return EXIT_SUCCESS;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include "indexDetails.h"
using namespace std;
IndexDetails::IndexDetails()
{
value = " " ;
diff = " " ;
}
void IndexDetails::Parser()
{
int k = 0;
while (k < line.length())
{
if ((line[k] == '<' )||(line[k] == '>' )||(line[k] == '/' ))
{
line[k] = ' ' ;
}
k++;
}
MatchPattern();
}
void IndexDetails::MatchPattern()
{
int num; int ptr = 0;
num = line.length();
while (ptr<num)
{
if (0 == strcmp("Dow" ,line.c_str()))
{
cout << "Index Name: " << "Dow" << endl;
getValue();
}
else if (0 == strcmp("Nasdaq" ,line.c_str()))
{
cout << "Index Name: " << "Nasdaq" << endl;
getValue();
}
else if (0 == strcmp("S&P 500" ,line.c_str()))
{
cout << "Index Name: " << "S&P 500" << endl;
getValue();
}
else if (0 == strcmp("FTSE 100" ,line.c_str()))
{
cout << "Index Name: " << "FTSE 100" << endl;
getValue();
}
else if (0 == strcmp("DAX" ,line.c_str()))
{
cout << "Index Name: " << "DAX" << endl;
getValue();
}
else if (0 == strcmp("Nikkei 225" ,line.c_str()))
{
cout << "Index Name: " << "Nikkei 225" << endl;
getValue();
}
else if (0 == strcmp("Hang Seng" , line.c_str()))
{
cout << "Index Name: " << "Hang Seng" << endl;
getValue();
}
else if (0 == strcmp("Straits Times Index" , line.c_str()))
{
cout << "Index Name: " << "Straits Times Index" << endl;
getValue();
}
else
{
cout << "None " << endl;
}
system("pause" );
}
}
void IndexDetails::getValue()
{
string check("id" ); size_t found; int y= 0; int digi;
while (y < line.length())
{
found = line.find(check);
if (found != string::npos)
{
digi = int (found);
if (isdigit(line[y]))
{
value = line[y] + value;
}
}
}
cout << "The value is:" << value << endl;
}
void IndexDetails::readFile()
{
ifstream inFile ("finance.htm" );
if (inFile.is_open())
{
while (!inFile.eof() )
{
getline(inFile,line);
Parser();
}
inFile.close();
}
else
cout << "Unable to open file" ;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
using namespace std;
class IndexDetails{
public :
IndexDetails();
void readFile();
void MatchPattern();
void Parser();
void getValue();
private :
string line;
string value;
string diff;
};
Last edited on Jan 27, 2010 at 4:30pm UTC
Jan 28, 2010 at 1:56am UTC
Please post the error message your compiler is giving.
Topic archived. No new replies allowed.