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;
}
#include<iostream>
#include<fstream>
using namespace test;
int main()
{
ifstream outFeb;
outFeb.open("febsales.txt"
if (outFeb.is_open())
{
while (!outFeb.eof())
{
// getline(outFeb);
}
}
else
{
cout << "File could not be open" << endl;
}
outFeb.close();
system("pause");
return 0;
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Error on line:
string myText = System.IO.File.ReadAllText ("C:\\febs ales.txt") ;
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Users\Kathleen\Documen ts\test.cp p" -o "C:\Users\Kathleen\Documen ts\test.ex e" -I"C:\Dev-Cpp\lib\gcc\ming w32\3.4.2\ include" -I"C:\Dev-Cpp\include\c++\ 3.4.2\back ward" -I"C:\Dev-Cpp\include\c++\ 3.4.2\ming w32" -I"C:\Dev-Cpp\include\c++\ 3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Users\Kathleen\Document s\test.cpp : In function `int main()':
C:\Users\Kathleen\Document s\test.cpp :11: error: `System' undeclared (first use this function)
C:\Users\Kathleen\Document s\test.cpp :11: error: (Each undeclared identifier is reported only once for each function it appears in.)
Execution terminated
string myText = System.IO.File.ReadAllText
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Users\Kathleen\Documen
C:\Users\Kathleen\Document
C:\Users\Kathleen\Document
C:\Users\Kathleen\Document
Execution terminated
C++? May be... Im not sure:
System::String *_myText;
_myText = System::IO::File::ReadAllText("C:\\febsales.txt");
Hey, you must include in your file:
#using <mscorlib.dll>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot.
NP. Glad to help : )
ASKER