Apr 17, 2012 at 4:23am UTC
I'm probably doing it wrong, but I am trying to make a program for my mum, she is a swim coach, it needed to make a textfile, put whatever my mums sessions where into the text file and it needs to keep doing that for however many activities and or sets her sessions have.
so she makes the first part, it puts it in and than she makes the second part it adds it in, but what is happening is it puts in the second part but erases the first part...
this first section is the first time she makes and activity ,
if it is horrific, I apologise, I'm self teaching for 3 weeks and knew absolutely nothing about programming ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
ifstream fileTextin("Swim-Sessions-In.txt" );
ofstream fileTextout("Swim-Sessons-Out.txt" );
fileTextin >> activSet >> activAct >> activAmount >> activDistence >> getWhat;
if (fileTextout.is_open())
{
while (fileTextout.good())
{
fileTextout << "SET " << activSet << ") " << activAct << ": "
<< activAmount << "x " << activDistence << ' ' << getWhat << endl;
fileTextout << fileTextin.rdbuf();
fileTextin.close();
fileTextout.close();
}
}
else cout << "\n*unable to open*\n" ;
second section is when she makes another SET...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
ifstream fileTextin("Swim-Sessions-In.txt" );
ofstream fileTextout("Swim-Sessons-Out.txt" );
fileTextin >> activSet >> activAct >> activAmount >> activDistence >> getWhat;
if (fileTextout.is_open())
{
while (fileTextout.good())
{
fileTextout << "\nSET " << activSet << ") " << activAct << ": "
<< activAmount << "x " << activDistence << ' ' << getWhat << endl;
fileTextout << fileTextin.rdbuf();
fileTextin.close();
fileTextout.close();
}
}
else cout << "\n*unable to open*\n" ;
third part if she makes another activity;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ifstream fileTextin("Swim-Sessions-In.txt" );
ofstream fileTextout("Swim-Sessons-Out.txt" );
fileTextin >> activAct >> activAmount >> activDistence >> getWhat;
if (fileTextout.is_open())
{
while (fileTextout.good())
{
fileTextout << "\n\t" << activAct << ": " << activAmount
<< "x " << activDistence << ' ' << getWhat << endl;
fileTextout << fileTextin.rdbuf();
fileTextin.close();
fileTextout.close();
}
}
else cout << "\n*unable to open*\n" ;
using these;
1 2 3
#include <iostream>
#include <fstream>
#include <string>
if it is really hard to answer, pointing me in the direction of what to learn about plus a bit of a description on it would be appreciated..
thanks in advance : )
Last edited on Apr 17, 2012 at 4:30am UTC
Apr 17, 2012 at 4:34am UTC
dude, thank you so much :), fixed ios::app, so simple :))