即使在程序结束后,我也想存储一个值 [英] I want to store a value even after my program ends

查看:183
本文介绍了即使在程序结束后,我也想存储一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



实现方法是什么?我想将一个字母存储到一个变量中,以便每当程序再次启动时,它可以在进一步的程序执行中使用这个变量。这个吗?

解决方案

不,你不能用变量来实现这个功能。 变量只存在,直到程序完成执行。一旦程序完成,没有变量被保留



您需要使用文件I / O 。您可以将一个执行的结束(最终)数据写入一个文件,下次运行程序时,它可以读取文件中包含的和 resume 的执行。



供您参考
$ b $

C



您可以在下面的库函数中检查



他们的家庭。
$ b

C ++




I want to store a letter into a variable so that whenever the program starts again it can use the variable in further program execution.

What is the way to achieve this?

解决方案

No, you cannot achieve this using variables. variables only exist untill the program finishes execution. Once the program is finished, no variable is retained.

You need to make use of file i/o. You can write the end (final) data of one execution to a file, the next time program runs, it can read the file contains and resume the exection.

For your reference,

In C

you can check below library functions

and their families.

In C++

这篇关于即使在程序结束后,我也想存储一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆