Help-me

clemilson

New member
Joined
Sep 8, 2003
Messages
1
Anybody know how read a text file and show your text in a variable?
Ex. one very simple text file with on text file ("Hello World" in hello.txt)

1. var1 = open the hello.txt
2. char *var = var1

Thanks
 
Are trying to do this using Managed Extensions? If yes then you can use the System::IO::StreamReader to read in the file and then assign it to a variable:
Code:
String* str; //string variable
System::IO::StreamReader* reads = new System::IO::StreamReader(S"hello.txt");
//new instance of StreamReader
str = reads->ReadToEnd(); //read the whole file using the ReadToEnd() method
reads->Close();
 
Originally posted by mutant
Are trying to do this using Managed Extensions? If yes then you can use the System::IO::StreamReader to read in the file and then assign it to a variable:
Code:
String* str; //string variable
System::IO::StreamReader* reads = new System::IO::StreamReader(S"hello.txt");
//new instance of StreamReader
str = reads->ReadToEnd(); //read the whole file using the ReadToEnd() method
reads->Close();
christ this sort of code is kinda scaring me into not learning VC++
 
Back
Top