AdamWalker
IS-IT--Management
can someone please tell me how to get full words and sentences into the category section of the following array. i tried declaring the char as category[20] but it doesn't seem to work. i am just beginning c++, please could someone help. thanks.
#include <iostream.h>
int main()
{
struct SiteType
{
int refNumber;
char category;
float siteVal;
}; // Note semi colon needed here
SiteType readings[5];
int index;
for (index = 0; index < 5; index++)
{
readings[index].refNumber = 1;
readings[index].category = 'A';
readings[index].siteVal = 3;
}
cout << "Reference Category Value" << "\n";
for (index = 0; index < 5; index++)
{
cout << readings[index].refNumber << " "
<< readings[index].category << " "
<< readings[index].siteVal << "\n";
}
}
#include <iostream.h>
int main()
{
struct SiteType
{
int refNumber;
char category;
float siteVal;
}; // Note semi colon needed here
SiteType readings[5];
int index;
for (index = 0; index < 5; index++)
{
readings[index].refNumber = 1;
readings[index].category = 'A';
readings[index].siteVal = 3;
}
cout << "Reference Category Value" << "\n";
for (index = 0; index < 5; index++)
{
cout << readings[index].refNumber << " "
<< readings[index].category << " "
<< readings[index].siteVal << "\n";
}
}