Please read this thread about how to post code inside code tags so that spaces and tabs are preserved. There are also other helpful threads for newbes at the top of this board that contain links to other useful information.
Thank you, and welcome to DaniWeb:)
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
I am taking a university C++ class, but this is my very first attempt to write a program on my own.
Thanks again. That makes sense. I didn't realize I could set the IF condition to make the input equal to a char. Thought it had to be an int value.
In C and C++ the char data type is an int -- it is a one-byte integer. There really is no such thing as a true character data type, the characters you see on the screen are represented internally as integers, for example the letter 'A' has a numeric value of 65. You can find out the values of all of them in an ascii chart. .
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Something like
int main( void )
{
char choice[2] = {'\0'} ;
do
{
fgets( choice, 2, stdin ) ;
choice[0] = tolower(choice[0]) ;
}
while ( choice[0] != 'y' && choice[0] != 'n' ) ;
return 0 ;
}
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734