In an or test || if the first condition is true the second conditon is not even tested for, thus in your if ((str_Status != "Sent") || (str_Status != "Cancelled by User")) (str_Status != "Sent") is true so the if statement is executed. Just use (str_Status != "Cancelled by User") as the sole condition.
Stye
Posts
-
problem with if statement -
C++ Question.Doing it the way you have you have to press the enter key twice after getline to get a response (the bug you were referring to). See http://support.microsoft.com/default.aspx?scid=kb;en-us;Q240015 for the fix ( the fix does work if you make the changes in the right file. The file referred to is in two different locations. You might as well change the code in both: MicrosoftVisualStudio\VC98\Include\String and MicrosoftVisualStudio\VC98\CRT\SRC\String I did and the enter key only has to be pressed once now and the code below which is like your way of doing it works fine. #include "stdafx.h" #include "string" #include "iostream" using namespace std ; int main(int argc, char* argv[]) { string s1; cout << "Enter a sentence:"; getline(cin,s1); if(s1 == "???" || s1 == "") cout << "First case"; else cout << "Second case"; return 0; }
-
C++ Question.I have 6.00 and works fine for me, try this out: #include "stdafx.h" #include "iostream.h" #include "string.h" int main(int argc, char* argv[]) { char line[100]; cout << "Type a line" << endl; cin.getline( line, 100); if(strcmp(line, "xxx") == 0) cout << "You entered xxx"; else cout << "You did not enter xxx"; return 0; }
-
C++ Question.Then simply use: cin.getline( line, 100) for the example given. The DEFAULT will be '\n' (carriage return) added as the final character when the return (enter) key is pressed.
-
C++ Question.Move the cin, e.g. char line[100]; cout << " Type a line terminated by 't'" << endl; cin.getline( line, 100, 't' ); cout << line;
-
Saving before closeAt some point use SetModifiedFlag(TRUE) and before closing have SaveModified() in the code.
-
Changing Dialog Font ProgrammaticallyDo you want to change the main dialog of a dialog based app or a dialog that is part of a doc view app? Do you want to change the dialog after it is already created or have a different font at creation depending a factor such as screen resolution, etc.?