Heres my current code:

const int SIZE = 100;		//constant 100
	const int COL = 30;			//number of columns
	int testScores[SIZE];		//test score array
	char students[SIZE][COL];	//student names array
	int numTests;				//the number of tests
	char *namePtr;				//char pointer
	int *numPtr;				//number pointer
	int count;					//counter

	numPtr = testScores;		//sets the pointer to testScores
	namePtr = students;                  //set the pointer to students

can pointers not be set to a char?
if that is the case should i just use an array?

I was told to use pointers whenever possible, i just don't know if a char pointer is possible.

9 Years
Discussion Span
Last Post by Duoas

> I was told to use pointers whenever possible
In C++ you should avoid both.

> i just don't know if a char pointer is possible.
Did you try compiling your code above? Did it complain about a char * ?

You can make a pointer to anything.

You'd be better off, though, using a std::string:

#include <string>
using namespace std;

string students[ SIZE ];

Of course, you have to keep track of how many students you actually have, and you can never have more than SIZE students.

You'd be best off, then, using a std::vector or std::deque:

#include <string>
#include <vector>
using namespace std;

vector<string> students;

students.push_back( "Jayne" );
students.push_back( "Ronnie" );
students.push_back( "Hannah" );

cout << "The students' names are:\n";
for (int i = 0; i < students.size(); i++)
  cout << student[ i ] << endl;

Hope this helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.