473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

I am having trouble with the toupper function.

I am tring to write a program that takes a input char and if it is lower case changes it to capital, then outputs the value. If it is already capital it just outputs the value. this is what i was thinking but it isnt working.
#include<iostream>
#include<cctype>
using namespace std;

int main()
{
char a;
cin >> a
while (cin.get(chr))
{
int toupper(a);
static_cast<char>(int) toupper(a));
cout << a;

}}
i guess my real problem is i really dont understand how the get function works with the int toupper.
Oct 15 '06 #1
2 2879
Banfa
9,065 Expert Mod 8TB
what is wrong with

Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.     char a;
  4.  
  5.     cin >> a
  6.     a = (char)toupper(a);
  7.     cout << a;
  8.  
  9.     return 0;
  10. }
  11.  
?
Oct 16 '06 #2
what is wrong with

Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.     char a;
  4.  
  5.     cin >> a
  6.     a = (char)toupper(a);
  7.     cout << a;
  8.  
  9.     return 0;
  10. }
  11.  
?
thanks a lot i think i was doin 2 much with it.
Oct 17 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Kerri | last post by:
Hi, I have a string 'hello world' I can UCase my string using String.ToUpper Is there anyway to just UCase the first letter ofe ach word? Thanks,
18
by: didgerman | last post by:
Chaps, I need to properly format the case of a struct. Can I just hit it with tolower, and then 'while (string ==' ') pos++; string=toupper(string); to add in the higher case for the start of...
0
by: Shrinivas Reddy | last post by:
Hi, I am using the ToUpper() function in an FXCop rule which checks whether a boolean variable has "is" or "has" as the prefix. The ToUpper() function does not work. When I put the expression...
48
by: Frederick Gotham | last post by:
The "toupper" function takes an int as an argument. That's not too irrational given that a character literal is of type "int" in C. (Although why it isn't of type "char" escapes me... ) The...
4
by: sandy | last post by:
I am trying to upper case a string, so I have this method: string FileSystem::toupper(string S) { for (int i=0; i<S.length(); ++i) { S=toupper(S); } return S;
13
by: JanWhitney | last post by:
I am learning C++, so please be kind. Is there anywhere that I can view the source code for the toUpper function? Thanks.
2
by: tracethepath | last post by:
i hav written a program code for reading characters from a text file and convert upper case characters to lower case and vice-versa. Converted characters need to be saved in a new text file and this...
16
by: gaga | last post by:
my function should accept a pointer to a string as its argument. and it should convert each charater to an uppercase letter. I know what i need to do, its just my syntax is all out of whack. ...
9
by: v0xx | last post by:
I am rather new to programming and to C++, and one concept I can't seem to wrap my head around is pointers and how to use them syntactically. I can comprehend the "int a=1; int *b=&a; int c=*b" line...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.