I have this enumerator that you read from a structure it says enum {PASSING, FAILING} it's meant to display failing or passing .. it does that however i get (status Failing0)(status PASSING1) as a final out put,... anyone knows why the 1 and the 0 are showing up? any tips on what to do?
if(info[i].average <70)
{
info[i].status = FAILING;
}
else
{
info[i].status = PASSING;
}
switch(info[i].status)
{
case FAILING: cout << "Status FAILING";// <<endl;
break;
case PASSING: cout << "Status PASSING";// <<endl;
}
cout << info[i].status <<endl;
Make a map:
#include <string>
#include <map>
enum TheEnumType { PASSING, FAILING };
std::map<TheEnumType, std::string> enum_names = { { PASSING, "Passing" },
{ FAILING, "Failing" } };
std::cout << enum_names[info[i].status];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.