?? can't retrieve data from .txt file...comes back blank????

so i'm trying to read in names and addresses from a .txt file into my program...but as of now i'm just trying to test my method of getting the data by getting one name from the .txt and posting it in my code but I am getting stuck at this point...i know that the problem is somewhere in the recieving and printing the data in my code in my .cpp file! but i can't seem to get it...any tips would be very appreciated!!!! Thank you!
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
//name.h

#ifndef NAME_H
#define NAME_H

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

#define ROW 100
#define COL 80

using namespace std;

class Name
{

    private:

       char ar[ROW][COL];

    public:


        void getName();
        void printName();
};

#endif 


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
//name.cpp

#include "name.h"

void Name::getName()
{


    stringstream ss;
    string fullName;

    ifstream myfile("people.txt");


    if(myfile.is_open())
    {

        while(! myfile.eof())
        {
            getline(myfile, fullName);
            cout << fullName << endl;
        }

       myfile.close();

    }

    else cout << "Unable to open file" << endl;
}
void Name::printName()
{

    for(int _row = 0; _row < 1; _row ++){
        for(int _col = 0; _col < 20; _col++){
            cout << ar[_row][_col];
        }
        cout << endl;
    }

}

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
//main.cpp

#include "address.h"
#include "date.h"
#include "name.h"
#include "gpa_ch.h"




using namespace std;

int main(){

    Name n;
    n.Name::getName();
    //n.printName();

    Address a;
    a.Address::getAddr("7839 Cary Court", "NONE", "Indianapolis", "IN", "46227");
    a.printAddr();

    Date d;
    d.Date::getDoB();
    d.Date::getDoG();
    d.printDate();

    gpa_ch g;
    g.getGPA();
    g.getCredit();
    g.print_gpa_ch();

    return 0;

}


here is my .txt file below


Nathan D Cruz
by the way the printName functino in the Name class isn't the issue with why it is not printing...it was a different technique i tried to use before hand...all that is needed to make it print should be in the .cpp file...that is where the problem is but i just can't find out what.
Topic archived. No new replies allowed.