string line

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?
Did you include string in your header?
yes...include<string>
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
Try using:
1
2
3
4
std::string
std::fstream
std::cout
std::endl
Last edited on
Topic archived. No new replies allowed.