toupper

J

JasBascom

if i have

struct crecord{
char record_type;
}

if record_type = 'c';

how do I make record_type toupper?
 
S

Sumit Rajan

JasBascom said:
if i have

struct crecord{
char record_type;
}

if record_type = 'c';

how do I make record_type toupper?



#include <iostream>
#include <cctype>

struct crecord {
char record_type;
};



int main()
{
crecord cr1, cr2;
cr1.record_type = 'c';
cr2.record_type = 'C';

cr1.record_type = std::toupper(cr1.record_type);
cr2.record_type = std::toupper(cr2.record_type);

std::cout << cr1.record_type << '\t' << cr2.record_type << '\n';

}


Regards,
Sumit.
 
M

Mike Wahler

JasBascom said:
if i have

struct crecord{
char record_type;
}

if record_type = 'c';

how do I make record_type toupper?

#include <iostream>
#include <locale>

struct crecord
{
char record_type;
};

int main()
{
crecord rec = {'c'};
std::locale loc;
rec.record_type = std::toupper(rec.record_type, loc);
std::cout << rec.record_type << '\n'; /* prints 'C' */
return 0;
}


-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top