ofstream file;
file.open("file.txt", ios::out);
std::string str = std::cout << filel;
4 Replies - 591 Views - Last Post: 28 March 2011 - 12:57 PM
#1
How to do assign file output from a stream to a variable
Posted 27 March 2011 - 06:43 AM
How do assign file output to a variable like this
Replies To: How to do assign file output from a stream to a variable
#2
Re: How to do assign file output from a stream to a variable
Posted 27 March 2011 - 07:48 AM
ofstrem output; // Output to file
ifstream input; // Input from file
input.open("file.txt", ifstream::in)
string str;
input >> str; // Copy a string from the file into your variable
input.close; // Close the file when done
Try these tutorials
Basic C++ File I/O, by bluesuus
C++ BEGINNER FILE PROCESSING TUTORIAL, by Elcric
EOF And Reading Text Files (C++), by Bench
File IO With Numeric Data, by
#3
Re: How to do assign file output from a stream to a variable
Posted 27 March 2011 - 07:54 AM
Please do not post help questions in the C++ Programmers Forum!!!
Moved to C and C++.
Moved to C and C++.
#4
Re: How to do assign file output from a stream to a variable
Posted 27 March 2011 - 08:12 AM
thanks
#5
Re: How to do assign file output from a stream to a variable
Posted 28 March 2011 - 12:57 PM
Hi i tried your method but when I use it in this code it doesn't set the value of the file output to the var. the file contains the number 3.
By the way, ignore the classes they are working fine
int player::set_stats()
{
stats pstats;
ifstream playerstats;
playerstats.open("player stats.txt", ifstream::in);
playerstats >> pstats.atk;
playerstats.close();
return pstats.atk;
}
By the way, ignore the classes they are working fine
This post has been edited by dastick: 28 March 2011 - 12:57 PM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|