basic i/o question cout<<str;
How can I modify the below text so that it couts all of example.txt?
If you want to answer another question:
1. How can I declare a string, for example
int a=0;
char a[256]=test; ((??))
[code]
#include <iomanip.h>
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <ctype.h>
int main()
{
char str[10];
//Used later
ofstream a_file("example.txt");
//Creates an instance of ofstream, and opens example.txt
a_file<<"This text will now be inside of example.txt";
//Outputs to example.txt through a_file
a_file.close();
//Closes up the file
ifstream b_file("example.txt");
//Opens for reading the file
b_file>>str;
//Reads one string from the file
cout<<str;
cout<<str;
cout<<str;
cout<<str;
cout<<str;
cout<<str;
cout<<str;
cout<<str;
//Should output 'this'
b_file.close();
//Do not forget this!
getch();
}
[c/ode]