在终止程序之前存储值 [英] Storing values before terminating program

查看:49
本文介绍了在终止程序之前存储值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

退出程序后,我可以使用什么函数/声明来存储值?我想将输出存储到变量中,并且在终止程序一次之后能够再次使用相同的值.发送帮助.

What function/declaration can I use to store a value after exiting a program? I want to store my output to a variable and able to use the same value again after terminating the program once. Send help.

推荐答案

文件C除了程序执行外,C还提供了用于存储数据的主要工具.这是程序已定义的可观察到的行为的一部分:

The primary facility C provides for storing data beyond program execution is files. This is part of the defined observable behavior of a program:

…在程序终止时,所有写入文件的数据应与根据抽象语义执行程序所产生的结果相同……这是程序的可观察的行为. (C 2018 5.1.2.3 6.)

… At program termination, all data written into files shall be identical to the result that execution of the program according to the abstract semantics would have produced… This is the observable behavior of the program. (C 2018 5.1.2.3 6.)

标准C不提供在程序结束后维护执行环境的数据存储内容的工具.在大多数情况下,如果要在程序执行之间保留对象的值,则应在程序结束前将其写入文件,并在程序启动后从文件中读取该对象.

Standard C provides no facility for maintaining the contents of data storage of the execution environment beyond the end of the program. For the most part, if you want to preserve the value of an object between program executions, you should write it to a file before the program ends and read it from a file after the program starts.

特定系统可能会提供扩展,这些扩展提供了持久存储数据的其他方式.共享内存是一项常见功能,有时用于存储数据的时间长于单个程序的执行时间,但不能通过系统重新启动来实现.

Specific systems may provide extensions that provide other ways of storing data persistently. Shared memory is a common feature, sometimes used to store data for periods longer than a single program execution but not through system reboots.

这篇关于在终止程序之前存储值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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