string line

Dec 20, 2011 at 12:48am
void E1() //function definition
{
char pilihan;
string line;
system("CLS");
fstream deposit;
deposit.open("customer.txt");
getline (deposit,line);
cout<< line <<endl;

can someone please tell me what is the use to declare string line in this code?
then, why is it the output line?
Dec 20, 2011 at 12:54am
Did you include string in your header?
Dec 20, 2011 at 1:15am
yes...include<string>
Dec 29, 2011 at 12:39am
your code:
1
2
3
4
5
6
7
8
9
10
void E1() //function definition
{
    char pilihan;
    string line; // This is an array of char's ... its a type in C++
    system("CLS");
    fstream deposit;
    deposit.open("customer.txt");
    getline (deposit,line); // this is where you read or input the data into line.
    cout<< line <<endl; // and this is where you output the data that is in "line".
}
Last edited on Dec 29, 2011 at 12:40am
Dec 29, 2011 at 12:54am
Try using:
1
2
3
4
std::string
std::fstream
std::cout
std::endl
Last edited on Dec 29, 2011 at 12:54am
Topic archived. No new replies allowed.