Jump to content

Syntax

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
restin84

restin84

    Learning Programmer

  • Members
  • PipPipPip
  • 53 posts
Hey new guy here

what is the correct syntax to use toupper on input using cin

example

char ans;
cin << ans; <-------------------- want it to be uppercase char to the computer regardless of if they use lower case or not

#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
You might be able to do something like the following. It has been a while since I have coded in C.

if(ans[0] >= 65 && ans[0] <= 90) 
ans[0] = ans[0]+32; 


#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
That will work on some system, not on others.

There is an uppercase flag you can set to control input/output.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
restin84

restin84

    Learning Programmer

  • Members
  • PipPipPip
  • 53 posts
well I'm using visual studio or xcode.

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
uppercase - C++ Reference
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog