Thread: Returning a static int as an int??

  1. #1
    Registered User
    Join Date
    Feb 2002

    Red face Returning a static int as an int??

    Hi all

    does any one know if it's correct to use a Static int and then return it as an int?

    for example
    int IncJobCount()
    static int job_count=0;
    return job_count;

    } thanx alot

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    To start at 0, all you need is
    static int job_count=0;
    return job_count++;

    To start at 1
    static int job_count=0;
    return ++job_count;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  3. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM