Sunday, May 10, 2009

C-language?

i want to write a C-program in which a number is incremented by a certain percentage each day.of course the inputted data will be stored in a file.





example:if i input a=100,increment=10% and store it in a file.next day when i open the file it should show a=110.





is it possible in C?if yes then tell me the header files and functions to be used to do the incrementation.

C-language?
Once you write something to a file, it is going to remain static until you do something else to it. That is, if your program writes 100 to a file, and you do nothing else to that file, then tomorrow when you open that file, it is still going to say 100. The file itself contains no logic. What you could do is write a program and schedule it to run every night at midnight. You could either harcode the increment, pass it as an argument, or have a 2nd program that has an input field and write the increment(and possibly the initial amount) to a configuration file of sorts. There are 100 ways to skin a cat and while you would still need something that run everynight to increment the value, there are numerous ways to give it the values.
Reply:use fstream to do files. ofstream for output to file. ifstream for input into the program from file.


No comments:

Post a Comment