Thread: How do I make a program remember what number it created laast time?

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    9

    How do I make a program remember what number it created laast time?

    I'm making a program where I use a function to solve a quadratic, and if the value of a is not zero, it checks if it it has real roots and I have to remember those numbers.

    The form is ax^2 + bx + c

    Later on in the program, I have to make it so that if I call the program and it has never been called before with an a value which was not 0, then it'll return some value.
    I don't know how to make it remember numbers or make it know if it's never been called before. I know something to do with static numbers.

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    > "Later on in the program, I have to make it so that if I call the program.."
    ^What does this line mean ? ...are you confusing 'function' with program ?
    If yes... you're on the right track... just declare a static variable inside the function to remember the 'state' data.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to make a c program run on boot time
    By muhammed irshad in forum Tech Board
    Replies: 6
    Last Post: 03-12-2011, 02:05 AM
  2. a program that will make the number i input to words
    By janjan in forum C++ Programming
    Replies: 4
    Last Post: 02-14-2011, 07:16 PM
  3. Replies: 2
    Last Post: 04-23-2008, 09:03 AM
  4. Does Anybody Here Remember When Hanz Gubenstein Invented Time Travel?
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 08-04-2005, 06:03 PM
  5. Replies: 4
    Last Post: 03-09-2002, 01:22 PM