Hi, im attempting to make a program that takes a name of up to 3 words long from a text file and outputs it into a different text file.

Then outputs numbers on a line below the name as well.

As there can be any number of names with their 12 numbers, im finding it hard to work out.

At the moment i can take the first name in the file and place it in an output file, but it does nothing with the numbers or other data in the text input file.

Also the way i have done it, if the name is only 1 or 2 words, it will end up outputting the first name then 1 or 2 numbers.

As an example the text file could contain the following:

David Smith

90 12 38 49 58 69 38 57 38 53 74 73

Liam David Smith

38 47 36 16 34 69 57 04 37 27 40 12




Heres what i have, any clues?

Code:
#include <iostream.h>
#include <string>
#include <fstream>
using namespace std;



bool getInputFilename(char fname[])
{
	ifstream fin;

	cout << "Please enter the filename for input : ";
	cin >> fname;
	
	fin.open(fname, ios::nocreate);
	
	if (!fin.is_open())
		return false;
	
	fin.close();
	return true;
}


bool getOutputFilename(char fname[])
{
	ofstream fout;

	cout << "Please enter the filename for output : ";
	cin >> fname;

	fout.open(fname);

	if (fout.fail())
		return false;

	fout.close();
	return true;

}

void firstArray(ifstream& fin, int marks [], char name[], char middleName[], char surname[])
{
	fin >> name >> middleName >> surname;
	 
	int i = 0;
	while (i < 12 && fin>>marks[i]) {
		i++;
	}
}






void main()
{
	ifstream fin;
	ofstream fout;

	char IFname[20], OFname[20];
	int marks [12];
	char name [20];
	char middleName[20];
	char surname[20];

	while (!getInputFilename(IFname))
	{
		cout << "Invalid filename try again!\n\n";
	}

	while (!getOutputFilename(OFname))
	{
		cout << "Invalid filename try again!\n\n";
	}

	fout.open(OFname);
	fin.open(IFname);

	firstArray(fin,marks, name, middleName, surname);

	fout << name << " " << middleName << " " << surname;


	fout.close();
	fin.close();

}