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 September 14th, 2004, 06:01 PM
xelimas xelimas is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 2 xelimas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Red face noob program ? loop

first off just want to say i know this ? is going to be really silly but i can't figure out how to break this loop i mean if u key in 'y' or 'n' the loop will continue...anyways anyone help?

Code:
  
#include <iostream>
 
using namespace std;
int main()
{
char decision;
while(decision='y')
{
 const int MaxSize=20;
 char barcode[MaxSize];
 
cout<<"Enter barcode: ";
cin>>barcode;
 
cout<<"Enter another barcode? (y or n): ";
cin>>decision;
}
 
return 0;
}

anyways i just started programming...also how do i get the char array back to an int array?
if anyone has a sugestion on how to do the loop a different way they are welcome =)
thanks ahead of time
oh btw, that isnt near the whole program =)

Reply With Quote
  #2  
Old September 15th, 2004, 02:52 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
You want while (decision == 'y') to do a comparison not an assignment.

You'll probably want the function atoi or strtol or something like that for conversion.

Hope this helps,

-KM-

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > noob program ? loop


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 3 hosted by Hostway