|
-
July 23rd, 1999, 09:37 PM
#1
input sngl char
How do I take in a input word but only look at the first character?
cin >> Minus
(but only look at the M)
-
July 23rd, 1999, 10:37 PM
#2
Re: input sngl char
Hi,
is this what you are asking?
char cFirstChar;
char Minus[20];
cin >> Minus;
cFirstChar = Minus[0];
Regards,
Paul Belikian
-
July 23rd, 1999, 10:44 PM
#3
Re: input sngl char
int main()
{
char command_character;
double r1;
double r2;
double acc;
cout.setf(ios::fixed, ios::floatfield); //Set up floating pt.
cout.setf(ios::showpoint); // output format
cout << setprecision(1);
DisplayMenu();//has a cout stating to type in char but if more than one letter is typed in it goes crazy.
cin >> command_character;
while ((command_character != 'Q') &&
(command_character != 'q'))
{
switch(command_character)
{
case '+':
case 'a':
case 'A':
Addition(r1,r2, acc);
break;
-
July 23rd, 1999, 11:05 PM
#4
Re: input sngl char
I think you need to make sure command_character is big enough to hold as many chars that could be typed in.
Right now char command_character is only 1 char long. You need to make an array and pass
only the first char...
#define MAX_INPUT_SIZE 100
int main()
{
char command_character[MAX_INPUT_SIZE];
double r1;
double r2;
double acc;
cout.setf(ios::fixed, ios::floatfield); //Set up floating pt.
cout.setf(ios::showpoint); // output format
cout << setprecision(1);
DisplayMenu();//has a cout stating to type in char but if more than one letter is typed in it goes crazy.
cin >> command_character;
while ((command_character[0] != 'Q') && (command_character[0] != 'q'))
{
switch(command_character[0])
{
case '+':
case 'a':
case 'A':
Addition(r1,r2, acc);
break;
Regards,
Paul Belikian
-
July 24th, 1999, 06:32 AM
#5
Re: input sngl char
Thanks,Paul my program is now finished, up and running
thanks to you!!!
Duane
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|