|
-
July 25th, 1999, 01:06 PM
#1
Need help Writing/Reading from text file in VC++
How can i read and write text to and from a text file? I was experimenting with this code, but it places some random text into the text variable and i get a bunch of access violations.
Here's the code:
ccode
#include <iostream>
#define _AFXDLL
#include <afx.h>
using namespace std;
int main()
{
char text[4];
const int max=10;
char letter[max];
CStdioFile file;
bool bSuccess = file.Open(("c:\_averyunlikelyname.txt"),
CFile::modeRead |
CFile::typeText
);
if (!bSuccess)
return FALSE;
file.ReadString(text,3);
cout << "The text from the file is: " << text;
cin >> "press enter to continue";
return 0;
}
/ccode
any help would be appreciated. thanks.
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
|