DEVC++ to VSC++2010 IDE

hello.. I am not a new visitor of this site, but this time, I need heroes to help my program work in another IDE which is the C++ vs2010 environment..

currently, I've been doing the C++ program in DEVC++ IDE, which gives me no headache at all.. now that I have a new IDE, the VS2010 c++, my program won't run anymore.. here's my code.. :)

for my "main.c"

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
#include <iostream>
#include <fstream>
#include "handler.h"
#include "daysched.h"
#include "writer.h"

using namespace std;

int main()
{       
    char choice;
    
    code_input: //start of program
    cout << "Enter code$ ";
    getline(cin, searchcode);

    readfile();     //handler.h
    if(searchresult==false)
    { goto code_input; }    //nothing has been found

    scheduler();   //daysched.h
    writeclass();  //writer.h

    cout << "Thank you for completing the fields." << endl << endl;
    cout << "End$ ";
    getchar();
    return 0;
}


my "daysched.h"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>

using namespace std;

string entryday[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};
string timein[100], timeout[100];

void scheduler();

void
scheduler()
{
       for(int daycount=0; daycount<5; daycount++)
       {
           cout << "-----------------------------" << endl;
           cout << "Schedule: " << entryday[daycount] << endl;
           cout << " TIME-IN$ "; 
           getline(cin, timein[daycount]);
           cout << "TIME-OUT$ ";
           getline(cin, timeout[daycount]);
           cout << "-----------------------------" << endl << endl;
       }
}


my "handler.h"

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
#include <iostream>
#include <fstream>

using namespace std;

string fname[100], mname[100], lname[100], gender[100], position[100], empcode[100], level[100];
string searchcode;

bool searchresult;
int loopx;

void readfile();

void
readfile()
{
   ifstream retrieve("employee.txt");
   if(retrieve.is_open())
   {
      for(loopx=0;!retrieve.eof();loopx++)
      {
          if(retrieve.good())
          {
              getline(retrieve, fname[loopx], ',');
              getline(retrieve, mname[loopx], ',');
              getline(retrieve, lname[loopx], ',');
              getline(retrieve, gender[loopx], ',');
              getline(retrieve, position[loopx], ',');
              getline(retrieve, empcode[loopx], ',');
              getline(retrieve, level[loopx], '\n');
              
              //replace the fname (underscore) to (space)
              replace(fname[loopx].begin(), fname[loopx].end(), '_', ' ');
              
              //search for employee's code using find method
              if(empcode[loopx].find(searchcode)!=string::npos || fname[loopx].find(searchcode)!=string::npos)
              {
                 cout << "----------------------------" << endl;
                 cout << "  First name: " << fname[loopx] << endl;
                 cout << " Middle name: " << mname[loopx] << endl;
                 cout << "   Last name: " << lname[loopx] << endl;
                 cout << "      Gender: " << gender[loopx] << endl;
                 cout << " Code number: " << empcode[loopx] << endl;
                 cout << "Salary level: " << level[loopx] << endl;
                 cout << "----------------------------" << endl;
                 cout << "Record found!" << endl << endl;
                 
                 searchresult=true;
                 break;
              }
              else if(!retrieve.eof())
              {
                   continue;
              }
              else
                  cout << "----------------------------" << endl;
                  cout << "Record not found." << endl;
                  cout << "----------------------------" << endl << endl;
                  searchresult=false;
          }
      }
   }
   retrieve.close();    
}


and my "writer.h"

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
#include <iostream>
#include <fstream>

using namespace std;

void writeclass();

void
writeclass()
{
    ofstream write("account.txt", ios::app);
    
    if(write.is_open())
    {
     write << "Data for: " << fname[loopx] << " " << mname[loopx] << " " << lname[loopx] << endl;
    
     for(int x=0;x<5;x++)
         {
                 write << "     Day: " << entryday[x] << endl;
                 write << " Time-in: " << timein[x] << endl;
                 write << "Time-out: " << timeout[x] << endl << endl;
         }
    }
    write.close();   
}


The error while compiling in VS2010 C++ is in my handler.h and it's the "replace()" function.. any help please? thanks.. :)
replace is a function of the class string. You have to call it on a string, like this:
someString.replace(....)
Last edited on
There is also replace() in algorithm. You need to include the header.
Next time say what the error is.
Thanks... Adding a header algorithm solved my problem.. There was no error on my program, as I said it is working on my DevC++ IDE.. Not in VS2010.. Thanks again.. algorithm saved it.. :)
Topic archived. No new replies allowed.