Click here to Skip to main content
15,889,116 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Error in calling DLL Pin
dafan25-Mar-04 2:41
dafan25-Mar-04 2:41 
GeneralA Loop...homework tips please! Pin
Joe Estes24-Mar-04 18:27
Joe Estes24-Mar-04 18:27 
GeneralRe: A Loop...homework tips please! Pin
Roger Wright24-Mar-04 19:54
professionalRoger Wright24-Mar-04 19:54 
GeneralRe: A Loop...homework tips please! Pin
Prakash Nadar24-Mar-04 20:16
Prakash Nadar24-Mar-04 20:16 
GeneralRe: A Loop...homework tips please! Pin
Roger Wright24-Mar-04 20:46
professionalRoger Wright24-Mar-04 20:46 
GeneralRe: A Loop...homework tips please! Pin
Prakash Nadar24-Mar-04 20:54
Prakash Nadar24-Mar-04 20:54 
GeneralRe: A Loop...homework tips please! Pin
Roger Wright24-Mar-04 21:00
professionalRoger Wright24-Mar-04 21:00 
GeneralRe: A Loop...homework tips please! Pin
peterzorbas24-Mar-04 21:40
peterzorbas24-Mar-04 21:40 
well my suggestion would be as follows.
int someFuntion(){
for(;;)// causes to loop infinite times, its 2 semicolons.
{
if(gets(c)=='x'){
return 0; //or break; /*breaks out of loop.*/
}
else{
keep going;
}
return 0;
}
i think the above is not a good model and is only necessary when nothing else would work. It is said that a clean program should have 1 entry point and 1 exit point. This does not follow that guideline.

the thing is there are so many things you can do with this.
such as

while(done!=1){
cin>>command;
if(command!='x')
{
done=0;
}
else
do more;
}


Also here is your problem. When you cin you recieve a string once you press the enter button. When you use the function toLower() in the ctype library you are comparing 1 char value. i think this would cause a segmentation fault(exception) if the user types XX by mistake. if you wish for 1 char then i think it would be appropriate to use something like getchar() or getch() not sure what the proper name is but use that instead. When you use C++ don't forget that C is a big part of the C++ language. It was necessary for C++ to be a superset of C simply because of simplification.

http://www-ccs.ucsd.edu/c/
GeneralRe: A Loop...homework tips please! Pin
peterzorbas24-Mar-04 21:58
peterzorbas24-Mar-04 21:58 
GeneralRe: A Loop...homework tips please! Pin
peterzorbas24-Mar-04 21:57
peterzorbas24-Mar-04 21:57 
GeneralRe: A Loop...homework tips please! Pin
Paul Ranson25-Mar-04 2:35
Paul Ranson25-Mar-04 2:35 
GeneralRe: A Loop...homework tips please! Pin
Roger Wright25-Mar-04 5:55
professionalRoger Wright25-Mar-04 5:55 
GeneralRe: A Loop...homework tips please! Pin
Paul Ranson25-Mar-04 6:42
Paul Ranson25-Mar-04 6:42 
GeneralRe: A Loop...homework tips please! Pin
Roger Wright25-Mar-04 7:59
professionalRoger Wright25-Mar-04 7:59 
GeneralRe: A Loop...homework tips please! Pin
Maxwell Chen25-Mar-04 16:55
Maxwell Chen25-Mar-04 16:55 
Generalsave application Pin
archanagaby24-Mar-04 17:44
archanagaby24-Mar-04 17:44 
GeneralRe: save application Pin
David Crow25-Mar-04 8:59
David Crow25-Mar-04 8:59 
GeneralSplit CString Pin
Simon Poon24-Mar-04 15:45
Simon Poon24-Mar-04 15:45 
GeneralRe: Split CString Pin
David Salter24-Mar-04 22:14
David Salter24-Mar-04 22:14 
GeneralRe: Split CString Pin
Steve S25-Mar-04 1:19
Steve S25-Mar-04 1:19 
GeneralAHAHAHA!!!! JSTL Pin
Snyp24-Mar-04 14:10
Snyp24-Mar-04 14:10 
GeneralRe: AHAHAHA!!!! JSTL Pin
Christian Graus24-Mar-04 15:17
protectorChristian Graus24-Mar-04 15:17 
GeneralRe: AHAHAHA!!!! JSTL Pin
Prakash Nadar24-Mar-04 15:31
Prakash Nadar24-Mar-04 15:31 
GeneralRe: AHAHAHA!!!! JSTL Pin
Nemanja Trifunovic24-Mar-04 18:39
Nemanja Trifunovic24-Mar-04 18:39 
GeneralRe: AHAHAHA!!!! JSTL Pin
Curi0us_George24-Mar-04 18:56
Curi0us_George24-Mar-04 18:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.