Yeah. Well, I didn't read rule one, so I didn't realise the whole thing about blocks. Here's my new code:
Code:
#include <stdio.h>
#include <fstream>
#include <iostream>
using namespace std;
void myflush(std::istream& in)
{
in.clear();
in.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
void mypause()
{
myflush(std::cin);
std::cin.get();
}
int main(void)
{
char str[10];
srand((unsigned)time(0));
ofstream a_file ( "example.txt" );
int random_integer;
for(int index=0; index<7; index++)
{
random_integer = (rand()%99)+1;
a_file << random_integer;
if (index) cout << ", ";
{
cout << random_integer;
}
}
cout << endl;
a_file.close();
mypause();
}