Link to home
Start Free TrialLog in
Avatar of mustish1
mustish1

asked on

Read string

Hi guys: Can any one please tell me how to read string from sequential file and than assign string to text line variable

#include<iostream>
#include<fstream>
using namespace test;
int main()
{
    ifstream outFeb;
    outFeb.open("febsales.txt", ios::in);
    if (outFeb.is_open())
      {
       while (!outFeb.eof())
         {
//        getline(outFeb);
          }
       }
     else
        {
           cout << "File could not be open" << endl;
        }
    outFeb.close();
    system("pause");
    return 0;
}
SOLUTION
Avatar of ulfur
ulfur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mustish1
mustish1

ASKER

Im sorry I have PIII laptop Im using the C++
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Error on line:
     string myText = System.IO.File.ReadAllText("C:\\febsales.txt");

Compiler: Default compiler
Executing  g++.exe...
g++.exe "C:\Users\Kathleen\Documents\test.cpp" -o "C:\Users\Kathleen\Documents\test.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
C:\Users\Kathleen\Documents\test.cpp: In function `int main()':
C:\Users\Kathleen\Documents\test.cpp:11: error: `System' undeclared (first use this function)

C:\Users\Kathleen\Documents\test.cpp:11: error: (Each undeclared identifier is reported only once for each function it appears in.)

Execution terminated
C++? May be... Im not sure:

System::String *_myText;
_myText = System::IO::File::ReadAllText("C:\\febsales.txt");

Open in new window

Hey, you must include in your file:
#using <mscorlib.dll>

Open in new window

I like this page:
Managed C++
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot.
NP. Glad to help  : )