PDA

View Full Version : help C++


s_0
03-16-04, 02:13 PM
im trying to make a prog to make a .txt with certain txt in it and i cant seem to get it to put the systemdir in their also trying to get it to make a random number within it too i have this so far
-

#include <iostream.h>
#include <fstream.h>
#include <cstdlib>
#include <ctime>

int main()
{
ofstream fout("test.txt");
fout << "testing GetSystemDir()" << endl;
fout << "testing rand()" << endl;
fout.close();
char str[20];
ifstream fin("test.txt");
fin >> str;
fin.close();
return 0;
}

any help would be lovely thx

daisycutter
03-17-04, 12:34 AM
im trying to make a prog to make a .txt with certain txt in it and i cant seem to get it to put the systemdir in their also trying to get it to make a random number within it too i have this so far
-

#include <iostream.h>
#include <fstream.h>
#include <cstdlib>
#include <ctime>

int main()
{
ofstream fout("test.txt");
fout << "testing GetSystemDir()" << endl;
fout << "testing rand()" << endl;
fout.close();
char str[20];
ifstream fin("test.txt");
fin >> str;
fin.close();
return 0;
}

any help would be lovely thx

Dunno but I could tell u how to do it in C

michaeln
03-17-04, 08:21 PM
I assume you are getting the following output to the file:
testing GetSystemDir()
testing rand()

You should change:
fout << "testing GetSystemDir()" << endl;
fout << "testing rand()" << endl;

to:
fout << "testing " << GetSystemDir() << endl;
fout << "testing " << rand() << endl;