clemilson Posted September 8, 2003 Posted September 8, 2003 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 Quote
*Experts* mutant Posted September 8, 2003 *Experts* Posted September 8, 2003 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: 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(); Quote
ICeMaN_179 Posted October 5, 2003 Posted October 5, 2003 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: 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++ Quote
spartanM19SSM Posted May 19, 2004 Posted May 19, 2004 I know, me too... I almost gave up on VC.NET and went to VB6.0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.