I know that this works: char text[] = "Hello";. How would I set text to a value read from a file? I tried doing this, but it didn't work:
#include <fstream>
using namespace std;
int main()
{
ifstream in("atextfile.txt");
char text[];
}
Some help, please?
I don't know what ifstream in() does?
You could do it this way:
| CODE |
#include <iostream.h> #include <conio.h> #include <fstream.h>
ifstream *f;
int main() { char text[10]; f=new ifstream("test.txt",ios::in,0); f->read(text,5); delete f; text[5]=0; cout<< text; getch(); return 0; }
|
Thanks, Xception. I'll see if that works.