Read the text file data

I compile the below program. i got
error :LINK1104: cannot open file "ap203lib.lib p28e2.lib rose.lib"

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
  #include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main ()
{
    string txt[10];
    string line;

    int i=0;
    ifstream file ("example.txt");
    if (file.is_open()){
        while (!file.eof()){
            getline(file,line);
            txt[i]=line;
            i++;
            }
        }
    file.close();
    
    for (int j=0; txt[j]!="\0"; j++)
        cout << txt[j] << endl;
        
    system("pause");
    return 0;
}

	

works fine for me
I guess you're using Visual Studio?

remove ap203lib.lib, p28e2.lib and rose.lib from your linker
yes, i remove that "ap203lib.lib, p28e2.lib and rose.lib " from linker. the error is cleared . but no output on the command prompt why?
there could be a bunch of reasons.
Did the file open correctly?
What's the content of example.txt?

what behaviour do you expect from that?
1
2
for (int j=0; txt[j]!="\0"; j++)
    cout << txt[j] << endl;
Last edited on
Topic archived. No new replies allowed.