| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
String problems
Hey, I'm having some trouble with strings... I'm farley new at C++ and am using the tutorial "http://www.cplusplus.com/doc/tutorial/index.html"
This tutorial does not show me the more complicated part of strings. I am trying to quit the program simply by typing quit, say I has this coding as an example... Code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int choice;
char qString[] = "quit";
cout << "1.choice number one" << endl;
bool menu = true;
while (menu == true)
{
if (choice == 1)
{
int choicetwo;
cout << "you have entered choice number one, type 'quit' to exit";
cin >> choicetwo;
if {choicetwo == qString)
{
menu == false;
return 0;
}
}
}
return 0;
}
see I don't really know how to do it but I think you know what I'm talking about. * sorry about the format of that code it got all screwed up while i was pasting* Last edited by CanadIan : April 11th, 2005 at 11:20 PM. Reason: I'm new at this forum stuff |
|
#2
|
||||
|
||||
|
a couple things, first, you don't have an input into "choice", but I don't know if that's your complaint
![]() also, you have an opening brace instead of parentheses on your last "if" statement ![]() the problem is that you are comparing "choicetwo" with "qString", but you're declaring "choicetwo" as an int, and "qString" as a character array, so comparing them will result in lots of fun change "choicetwo" to be a character array and you should be fine.... |
|
#3
|
|||
|
|||
|
YEAH thats it... I was getting errors saying i cant convert an int to a string or somthing ... thanks a ton man
ps: I made that code in like 2 seconds so thats why its a little sloppy, hence the brace typo |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > String problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|