|
-
Dec 31st, 2002, 06:00 PM
#1
Thread Starter
Addicted Member
Saving and Opening files (C++)
I need to be able to save and open files for a simple boot-up text editor. Can someone tell me how to use the header files ifstream.h and ofstream.h ?
I suck with graphics. Can you help me out? If you are good with graphics there are rewards . . . email me, [email protected] . . .
[img src="www.cel-eration.com/anim1.gif"][/img]
-
Dec 31st, 2002, 08:06 PM
#2
Hyperactive Member
Here's a simple tutorial from GameDev,
http://www.gamedev.net/reference/art...rticle1127.asp
Hope it helps!
-
Dec 31st, 2002, 11:36 PM
#3
<fstream.h> is deprecated. Use <fstream>
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 2nd, 2003, 07:51 AM
#4
Hyperactive Member
C-Style:
PHP Code:
#include <stdio.h>
int load(char* sz)
{
char szBuffer[1024];
FILE* f = fopen(sz, "r");
if(!f)
return -1;
while(fgets(szBuffer, 1024, f))
{
printf("%s\n", szBuffer);
}
fclose(f);
return 0;
}
int save(char* sz, char* szSave)
{
FILE* f = fopen(sz, "r");
if(!f)
return -1;
fprintf(f, szSave);
fclose(f);
return 0;
}
-
Jan 2nd, 2003, 09:28 AM
#5
Frenzied Member
but he was asking for C++:
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream in("input.txt");
ofstream out("output.txt");
string str;
char c = in.get();
while(c != EOF)
{
str += c;
cout << c;
out.put(c);
c = in.get();
}
cout << endl;
cout << str << endl;
return 0;
}
Last edited by wey97; Jan 2nd, 2003 at 09:37 AM.
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
|
Click Here to Expand Forum to Full Width
|