Epison07
October 28th, 2004, 03:40 AM
Ok, Again with my lyrics database. I have yet to actually start this project, because I am still playing around with different ways to to store the lyrics. But I am trying to play with creating a text file and put the lyrics in there and then everytime you run the program, it will just read the text into the approiate variables. Well, I havent quite got that far into this. ..
//Test
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char fileName[80] = "D:\Junk\C++\Text.txt";
char buffer[256];
ofstream fout(fileName);
fout<<"Hello...\n";
fout.close();
ifstream fin(fileName);
char ch;
while(fin.get(ch))
{
cout << ch;
}
system("PAUSE");
return 0;
}
When I first ran this program, I did not write anything to the file, I wanted to just read it. Well, I couldnt get it to work. Well, I have a C++ book right in from of me and just copied a section of the code. And now it works. Problem, Instead of writing and reading to the text file I have created in D:\Junk\C++, the program creates a file in my C++ folder called "JunkC++Text". I am wondering why it does it, and if there is a way I could get the program to read/write to files that are not in the same folder as the compiler its self. Any help is great. Thanks in advance.
-Ep
//Test
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char fileName[80] = "D:\Junk\C++\Text.txt";
char buffer[256];
ofstream fout(fileName);
fout<<"Hello...\n";
fout.close();
ifstream fin(fileName);
char ch;
while(fin.get(ch))
{
cout << ch;
}
system("PAUSE");
return 0;
}
When I first ran this program, I did not write anything to the file, I wanted to just read it. Well, I couldnt get it to work. Well, I have a C++ book right in from of me and just copied a section of the code. And now it works. Problem, Instead of writing and reading to the text file I have created in D:\Junk\C++, the program creates a file in my C++ folder called "JunkC++Text". I am wondering why it does it, and if there is a way I could get the program to read/write to files that are not in the same folder as the compiler its self. Any help is great. Thanks in advance.
-Ep