#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    C++ Primer - Stuck on first chapter


    Hi I'm stuck on this question in the very first chapter of C++ Primer (5th edition):

    hxxp://ideone.com/4QlDm

    here is the segment before it:

    hxxp://ideone.com/tlrsc

    the only other things covered so far are cin/cout, if/while/for and adding numbers.

    This has been wregking my head for days I've been looking gor a solution online but to no avail. A solution with only chapter material would be freatly appreciated. I also can't seem to satisfactorally add Sales_items:

    hxxp://ideone.com/XeAx2

    and here is Sales_item.h if you want to test your solutions before posting them:

    hxxp://ideone.com/U1vCo

    Thanks in advance!
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,379
    Rep Power
    1871
    > 123-123-123-X 2 33
    If this is a line of input, then you need something like

    Code:
    while ( std::cin >> isbn >> quantity >> unitprice ) {
      // do stuff
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo