Hi, this code is merely for testing a coulpe of functions for use in a bigger program, therefore this code alone may seam silly, but there is a point to it:)
When i run this and press "1" the program just terminates, pressing "2" or "whatever here" works fine however? so, what am i doing wrong guys?
#include <iostream>
#include <fstream>
using namespace std;
void skrivtilfil (string placering);
void laesfrafil ();
int main()
{
int ioro;
cout << "in or out? ";
cin >> ioro;
if (ioro == 1)
{
string plac;
getline (cin,plac);
skrivtilfil (plac);
}
else if (ioro == 2)
{
laesfrafil ();
}
return 0;
}
void skrivtilfil (string placering)
{
ofstream skrivtraed;
skrivtraed.open ("Seek and Hide DB.ini",ios::app);
skrivtraed << placering, "\n";
skrivtraed.close ();
}
void laesfrafil ()
{
string line;
ifstream laestraed;
laestraed.open ("Seek and Hide DB.ini");
while (! laestraed.eof() )
{
getline (laestraed,line);
cout << line;
}
laestraed.close();
}