Hi guys,
I'm having issues passing structure name (student) when calling function countValues. I would like to pass structure student + resArray so I can assign values to numRes and mumNonRes that belong to student structure. Thanks for your help in advance.
#include <iostream>
#include <cstring>
using namespace std;
char* resArray;
int size;
student stu;
cout << "Enter the number of input values: ";
cin >> size;
resArray = new char(size);
inputArray(resArray, size);
countValues(resArray, size); // how do I pass structure student when calling function countvalues.
stu.displayResCount();
return 0;
}
void inputArray(char resArray[], int size)
{
for (int i = 0; i < size; i++)
{
cout << "Enter r or n:# ";
cin >> resArray[i];
}
}
void countValues(char resArray[], int size)
{
student ste; // using struct like this only works inside this function.
for (int i = 0; i < size; i++)
{
if (resArray[i] == 'r' || resArray[i] == 'R')
ste.numRes++;
else if (resArray[i] == 'N' || resArray[i] == 'n')
ste.numNonRes++;
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.