I have a two dimensional array that I need to make into a global variable to be able to access it from other functions. I can't quite figure out what the correct syntax is.
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void ReadStudents (string Students);
void ConvertToInt (string Students[]);
void main ()
{
string Students[10][3];
ReadStudents (Students[]);
ConvertToInt (Students[10][3]);
}
//Function to read in students Grades
//Read it into a two Dimensional Array
void ReadStudents (string Students[])
{
fstream infile;
int i, j;
infile.open ("c:\\students.txt");
//While not EOF read the Tab seperated file
while (!infile.eof())
{
for (i = 0; i < 5; i ++)
{
for (j = 0; j < 3; j++)
infile >> Students[i][j];
}
}
infile.close ();
}
//Function to convert third row to and int
void ConvertToInt (string Students[10][3])
{
int i;
int j = 2;
for (i=0; i < 5; i++)
{
cout <<Students[i][j] << " ";
cout << endl;
}
}