Urgent: How to get bool data to output to table?
I need to output the data from when my bool (seen below) is false, into the table (seen further below)
1 2 3
|
//check the answers for invalid data
else if ( answer!= int("F") && answer !=int("T"))
StRec.dataFlag[stIndex] = true;
|
This is the table:
1 2 3 4 5 6 7 8 9 10 11 12
|
//Prints Table Data
void PrintTableData(Records StRec)
{
for (int index = 0; index < NUM_OF_STUDENTS; index++)
{
cout << left;
cout << setw(22) << StRec.Names[index]
<< setw(14) << StRec.examScore[index]
<< StRec.Answers[index]
//<< StRec.dataFlag<< endl;
}
}
|
The bool is part of a struct:
1 2 3 4 5 6 7
|
struct Records
{
string Names[NUM_OF_STUDENTS];
string Answers[NUM_OF_STUDENTS];
int examScore[NUM_OF_STUDENTS];
bool dataFlag[NUM_OF_STUDENTS];
} studentRecords;
|
How do I do this?
based on the title, do you want to print either true
or false
?
if so, you can do something like :
1 2 3 4 5 6 7 8 9 10 11
|
#include <iostream>
using namespace std;
int main()
{
bool b = true;
cout << static_cast<const char*> (b ? "true" : "false" ) << endl;
// or simply :
cout << (( b) ? "true" : "false");
}
|
is this what you mean ?
EDIT
oh wait, do you mean :
1 2 3 4 5 6 7 8
|
for( int i = 0; i < NUM_OF_STUDENTS; i++ )
{
cout << left;
if( ! stRec.dataFlag[ i ] ) // if false :
// Print other info's
}
|
Last edited on
Topic archived. No new replies allowed.