My mind is not blown; I am merely attempting out of dull dreary habit to teach you something which you don't particularly seem to want to know. I admit to mild curiosity as to whether you just ignored the errors and used the old executables or changed the input file with or without realizing it and just aren't owning up to it, but I can live without knowing that.
Anyway, I'll let you ask a question about your debug problem before going on about that.
Shrug. We're going to have to go with hallucinations, it seems. As far as I know, if there is an error with compiling, Dev_C++ would clue me in on this and the .exe would not be compiled (you made mention of getting some sort of temp.exe? this however was not the case for me). I am certainly not too proud to admit to making mistakes at this point in the game, and if that were the case I would gladly admit it. I am simply recounting the situation as I experienced it and really do find it a tad distressing for one reason or another that apparently that this situation is without a doubt impossible. Perhaps someone happened that I didn't even realize? I don't know. Either way, I apologize for my ignorance if this is the case, and assure you I am being wholeheartedly sincere about the situation.
As far as my debug problem goes, you know what it is, you can help if you'd like, I will of course try to figure it out on my own. Posting on a code forum was not close to my first step in figuring out this problem originally, and I only did so because the situation i was in left me scratching my head.
That seems like a pretty silly assumption. If you open up a word doc, make some changes, and then exit Word without saving, your old document is still there. Same deal here -- you tried to change your .exe, it failed, so your old .exe is still there. (That's under the assumption that you had a version without this line in it.)
Are you printing the chars from the program? From gdb? When are you printing?
this is the thing, i didn't have an earlier version where i had the correct else if statement. But we should stop talking about this, yes? Beating a dead horse, and probably making myself look even more incompetent.
I am running Eclipse in Debug mode, tracing through the steps individually. Here's a screen shotAre you printing the chars from the program? From gdb? When are you printing?
and pasted below is the updated version of the code;
Thank you again for taking the time to help.Code:#include <iostream> using namespace std; int main() { cout << "Enter a Number Between 10-99: "; char tens, ones; cin >> tens >> ones; if (tens == 1) switch (ones) { case '0' : cout << "Ten"; break; case '1' : cout << "Eleven"; break; case '2' : cout << "Twelve"; break; case '3' : cout << "Thirteen"; break; case '4' : cout << "Fourteen"; break; case '5' : cout << "Fifteen"; break; case '6' : cout << "Sixteen"; break; case '7' : cout << "Seventeen"; break; case '8' : cout << "Eighteen"; break; case '9' : cout << "Nineteen"; break; } else if (tens >=2){ switch (tens) { case '2' : cout << "Twenty"; break; case '3' : cout << "Thirty"; break; case '4' : cout << "Fourty"; break; case '5' : cout << "Fifty"; break; case '6' : cout << "Sixty"; break; case '7' : cout << "Seventy"; break; case '8' : cout << "Eighty"; break; case '9' : cout << "Nintey"; break; default: cout << "Number not within allowed range" << endl; } switch (ones) { case '0' : cout << " "; break; case '1' : cout << " one"; break; case '2' : cout << " two"; break; case '3' : cout << " three"; break; case '4' : cout << " four"; break; case '5' : cout << " five"; break; case '6' : cout << " six"; break; case '7' : cout << " seven"; break; case '8' : cout << " eight"; break; case '9' : cout << " nine"; break; default: cout << "Number not within allowed range" << endl; } } }
Alright. So we should have tens == '1' for sure. Now my mind is blown: 27 is ESC, of course, and [ means that we're looking at good old ANSI terminal escape codes, which seems both outrageous and distressing Do you have a setting for that in Eclipse? (You've gotten farther along in using Eclipse for C++ then most people I meet so perhaps this is some quirk of Eclipse I've not come across.) I've not used Cygwin in a while either, but I don't remember it introducing escape sequences when reading characters.
I don't believe I have a setting for that in Eclipse [I have not fooled around much with the settings in Eclipse at all, and am thinking I may try a clean install of it because I don't like that I am getting escape chars when I am clearly entering valid numeric characters] .
I believe it is worth mentioning that in my earlier post i mentioned that I was receiving these values [ 27 and ']' ]when I entered 16 as my input, but after running another debug session 16 was input correctly [1 in the tens, 6 in the ones], but Eclipse still blew right by switches under if (tens==1) and i was not receiving the correct output.
edit: I do however receive correct outputs when my input is within the 20-99 range.
Definitely not thinking of ASCII So just to make sure I am on the proper page here; Would it be incorrect to even try to do a condition like else if (tens >=2)?? Or can C++ still take this sort of condition into consideration despite the fact that the variable is a char and not an int.
You can do tens >= 2 -- that would just check whether the character tens had an ASCII value greater than or equal to two.
I'm not really sure what you'd like to do, but this code may help you.
Code:// Computer Science - Lab 2b // Outputing Text Format of Numbers 10-99 // Adam Davis - 09/06/09 #include <iostream> #include <string> using namespace std; char* number[10] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; int main(void) { char command[10] = {0}; int i; scanf("%9s", command); if( isdigit(command[0]) && (command[1] == '\0') ) printf("%s\n", number[command[0] - '0']); else for (i = 0; i < 10; i++) if(strncmp(command, number[i], strlen(number[i])) == 0) printf("%d\n", i); return 0; }
P.S.
And you can customize for how many numbers you would like, of course.