Creating a sequential file
来源:互联网 发布:网址导航 源码 编辑:程序博客网 时间:2024/05/04 23:44
#include<stdio.h>
int main()
{
(Each open file must have a separately declared pointer of type FILE that is used to refer to the file.)
File *cfPtr; //cfPtr = clients.dat file pointer //cfptr is a pointer to a FILE structure
//fopen opens file. Exit program if unable to create file.
(fopen takes two arguments: a file name and a file open mode.)
(the file open mode "w" : the file is to be opened for writing . If a file does not exist ,fopen creates the file.If an existing file is opened for writing , the contents of the file are discarded without warning.)
if( ( cfPtr = fopen( "clients.dat","w") ) == NULL ){
printf("File could not be opened/n");} //end if
else{...}
//write information into file with fprintf
(feof to determine whether the end-of -file indicator is set for the file to which stdin refers.
(Windows <ctrl>z ; UNIX <return><ctrl> d end-of-file key combination)
The argument of function feof is a pointer to the file being tested for the end-of-file indicator .The function returns a nonzero(true) value when the end-of-file indicator has beenhas been set; otherwise , the function returns zero.)
while( ! feof(stdin) ) {
(Function fprintf is equivalent to printf except that fprintf also receives as an argument a file pointer for the file to which the data will be written.)
fprintf(cfptr,"%d %s %.2f/n", account , name , balance);
scanf("%d%s%lf", &account , name , &balance);}
( ( fclose receives the file pointer (rather than the file name) as an argument.) If funcion fclose is not called explicitly, the operating system normally will close the file when program execution terminates.)
fclose(cfPtr); // indicates successful termination
return 0 ;
}
- Creating a sequential file
- 在服务器端创建文件(create a sequential file)
- Creating a CAB file for your application
- Creating a File Manager in Adobe Air
- Re-creating a Password Authentication File
- Creating and Using a Temporary File
- db file sequential read
- db file sequential read
- db file sequential read
- control file sequential read
- db file sequential reads
- 将服务器上的文件内容读到内表(read a sequential file)
- db file sequential read事件
- 模拟DB File Sequential Read
- db file sequential read 详解
- Creating a custom server.xml file with Tomcat
- Creating a Data dictionary file to use with LogMi
- Creating a Root File System for Linux on OMAP35x
- 环境配置
- SqlDataReader
- C File Processing
- 【转载】Java文档注释编写格式
- 冲突域和广播域
- Creating a sequential file
- JAVA四种基本排序,包括冒泡法,插入法,选择法,SHELL排序法
- osi
- 网络基础
- 用C++编写自动关机程序
- 全双工以太网
- 以太网电缆的连接
- 导致 LAN拥 塞的可能原因
- αsco3层 模型中的3个 层次