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

This is a discussion on How do I make a program remember what number it created laast time? within the C Programming forums, part of the General Programming Boards category; I'm making a program where I use a function to solve a quadratic, and if the value of a is ...

  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
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    > "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.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



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, 01: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, 06: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, 12:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21