Linux 打开文件并写入一段字符串,同时读出对应文件的信息
在Linux中,采用C语言,使用fopen()函数打开一个文件(若不存在文件,则新建一个 如 data/test.dat),同时采用
fwrite()向其中写入相应的字符串,每次输入写入都换行,最后采用fread()读出相应的信息。
相应的代码如下:Test.c
/*
Test.c :create a file : Write a string to the file
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 128
int
m