Thread: struct

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    struct

    Hey guys just a simple question just say if i want to increment an integer which is declared in the struct how would i do it?

    iv done

    Code:
     
    submenuCurrent->qtySold[SMALL] +1;
    i get a statement with no effect? not sure how the expression is suppose to go

  2. #2
    Math wizard
    Join Date
    Dec 2006
    Location
    USA
    Posts
    582
    That should be += 1 or just ++.

    Code:
    submenuCurrent->qtySold[SMALL] += 1; // one method - note the = being included
    submenuCurrent->qtySold[SMALL] ++; // increments a variable by 1, another method
    Last edited by ulillillia; 05-11-2007 at 03:26 AM. Reason: Forgot closing code tag
    High elevation is the best elevation. The higher, the better the view!
    My computer: XP Pro SP3, 3.4 GHz i7-2600K CPU (OC'd to 4 GHz), 4 GB DDR3 RAM, X-Fi Platinum sound, GeForce 460, 1920x1440 resolution, 1250 GB HDD space, Visual C++ 2008 Express

  3. #3
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252
    Thanks got it and all works good

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 12-03-2008, 03:10 AM
  2. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  3. Replies: 10
    Last Post: 05-18-2006, 11:23 PM
  4. What's wrong with my search program?
    By sherwi in forum C Programming
    Replies: 5
    Last Post: 04-28-2006, 09:57 AM
  5. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM