|
-
October 28th, 2004, 02:40 AM
#1
Member
Reading and Writing
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. ..
Code:
//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
01001001001000000100110001101111011101100110010100100000010000100110010101110100011101000111100100100001
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|