I want to do two-dimensional array..

STUDENT1 take 001, 003, 005,006
STUDENT2 take 005, 007, 009, 001

001 002 003 004
like this 001 0 2 1 ....
002
003
004

and I do a programming like below, but how to fill inside the { }?

// --------------------------------------------------------------
// Read a file of Stu83.txt
// Count number of ExamID in following ranges
// --------------------------------------------------------------


#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cassert>
#include <stdlib.h>
using namespace std;

// =========================
// Global Declarations
// =========================
const int NUM_EXAMID = 140


int var_name[140]; // C++ Array of type int with maximum size = 10000.
int array_matrix[140][140]; //Matrix of 3 * 3 type using c++ array of int data type
// =========================
// Main Function
// =========================
int main()
{
	ifstream stream1 ("STA83STU.txt");
	string filename;
	double examid[NUM_EXAMID];  // declares 10 scores
	// Prompt user for the file name

	cout << "Enter input file name containing scores: ";
	getline(cin, filename);

	infile.open(filename.c_str());

	// Validate that the input file opened successfully
	assert(infile);
	char lgrade;
	int Acount = 0, Bcount = 0, Ccount = 0, Dcount = 0, Fcount = 0, invalidcount = 0;

	for ( int i = 0; i < NUM_EXAMID; ++i)
	{
		infile >> examid[i];
		

		switch (ltotal)
		{
			
		}
		
		cout << examid[i] << " => " << ltotal << endl;  
	}

	// Display counter statistics


	infile.close();
	
	// TODO: Write a function printArray that prints the entire array
	// of scores.  Pass the array in as a parameter.

		cout << "Enter input file name containing examid: ";
	getline(cin, filename);

	infile.open(filename.c_str());

	// Validate that the input file opened successfully
	assert(infile);

	printScores(scores, NUM_EXAMID);



	return 0;
}




void printExamID(const double s[], int len)
{
	

}

line 30: why is that a double instead of an int ? Do exam IDs contain decimal places ?

line 39: assert does nothing if the program is not compiled for debug. And it does not stop the program if the file fails to open. In otherwords, its not useful for what you are trying to use it for. Instead you should test for valid opening

if( !infile.is_open())
{
   cout << "File not opened\n";
   return 1; // don't continue the program
}

line 48: I don't know what you want to do in that switch statement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.