We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Read string

Medium Priority
306 Views
Last Modified: 2013-12-16
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;
}
Comment
Watch Question

Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Im sorry I have PIII laptop Im using the C++
Carlos VillegasFull Stack .NET Developer
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
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
Carlos VillegasFull Stack .NET Developer

Commented:
C++? May be... Im not sure:

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

Open in new window

Carlos VillegasFull Stack .NET Developer

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

Open in new window

Carlos VillegasFull Stack .NET Developer

Commented:
I like this page:
Managed C++
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Thanks a lot.
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
NP. Glad to help  : )
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.