Sorry typing error...
if(buff[0]=='Q')
Please try a example....first while loop is okay. Second time onwards it crashes
Main Topics
Browse All Topicschar buff[50];
while(1)
{
cout << "Enter Series of string. Q to quit" << endl;
memset(buff, ' ', 50);
......
if(buff[0]='Q') //Partially O.k, crashes the second or third or fourth ... time
return 0;
else
continue;
}
Please correct the abobe code.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
with = it exits the first time
with == it loops forever
neither crash
does your program do anything else?
#include <iostream>
#include <string.h>
using namespace std;
main(){
char buff[50];
while(1)
{
cout << "Enter Series of string. Q to quit" << endl;
memset(buff, ' ', 50);
//......
if(buff[0]=='Q') //Partially O.k, crashes the second or third or fourth ... time
return 0;
else
continue;
}
}
Dear PaulCaswell, forgive me but I want to tell something, not blame me for this, just I tell it for fun...
You recently become moderator and you need to show us a bit you are a moderator, that's why you blamed Infinity08, otherwise his comment have no problem, he was right, question is completely general and he can't get right answer with such question.... :P
Don't become angry, I just joked :P But I understood you are a moderator :D :p :)
Thank you for the support, both, but there's no problem. Paul has been around longer than me ;) And he's very good at keeping us all in check, and focused on helping out and providing a good atmosphere for everybody. That is very much appreciated btw, Paul. Don't think that's said enough.
My post might have sounded a bit harsh, but it sure wasn't meant that way. It just seemed my advice that more information is needed to get the best help possible was overlooked twice - I didn't want it to get overlooked a third time ;)
Business Accounts
Answer for Membership
by: Infinity08Posted on 2008-07-21 at 15:58:06ID: 22055171
First of all, it's NOT C code. It's C++.
>> if(buff[0]='Q')
Should probably be :
if(buff[0]=='Q')