Harish Hi,How to store a variable value for more than one executions. Ex: main(){int i=0;i++;printf("%d",i);} For first execution output should be 1For Second execution output should be 2 nth exection output should be n Any help is appreciated Thnaks in AdvanceHarish 推荐答案 ha ****** @ gmail.com 写道: ha******@gmail.com wrote: 如何为多个执行存储变量值。 不止一次执行?如果不诉诸外部 存储空间是不可能的,唯一的标准类型是文件。 main() { int i = 0; i ++; printf("%d",i); } 对于第一次执行输出应为1 第二次执行输出应该是2 How to store a variable value for more than one executions.More than one execution? Can''t be done without resorting to externalstorage, the only Standard kind of which are files. main() { int i=0; i++; printf("%d",i); } For first execution output should be 1 For Second execution output should be 2 像这样,你不能这样做。你需要在程序结束时将i的值写入 文件,然后在你下次执行 时再读回来。没有像静态但更大的关键字,如果那是' 你想要的东西。 Richard Like this, you can''t do that. You''ll need to write the value of i to afile at the end of the program, and then read it back when you start thenext execution. There is no keyword like "static-but-larger", if that''swhat you were looking for. Richard ha******@gmail.com 写道: ha******@gmail.com wrote: 如何为多次执行存储变量值。 例如: main() { int i = 0; i ++; printf("%d",i); } 对于第一次执行输出应为1 第n次执行输出应为n How to store a variable value for more than one executions. Ex: main() { int i=0; i++; printf("%d",i); } For first execution output should be 1 For Second execution output should be 2 nth exection output should be n 您可以将i的值存储在文件中,或者在环境变量中。 You could store the value of i in a file, or in an environment variable. Grumble< de ***** @ kma.eu.org>写道: Grumble <de*****@kma.eu.org> wrote: ha******@gmail.com 写道: ha******@gmail.com wrote:如何为多个执行存储变量值。 How to store a variable value for more than one executions. 您可以将i的值存储在文件中,或者一个环境变量。 You could store the value of i in a file, or in an environment variable. 在文件中,是的,但是如何从C设置环境变量? Richard In a file, yes, but how do you set an environment variable from C? Richard 这篇关于如何为多个执行存储变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-11 11:29