C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 11th, 2005, 11:18 PM
CanadIan CanadIan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 2 CanadIan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 42 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old April 12th, 2005, 12:24 AM
B-Con's Avatar
B-Con B-Con is offline
:bcon: moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: int main()
Posts: 351 B-Con User rank is Private First Class (20 - 50 Reputation Level)B-Con User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 23 h 1 m 43 sec
Reputation Power: 4
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....

Reply With Quote
  #3  
Old April 12th, 2005, 06:45 PM
CanadIan CanadIan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 2 CanadIan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 42 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > String problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway