code 文件的保存、读取
来源:互联网 发布:自制手机铃声软件 编辑:程序博客网 时间:2024/05/24 08:34
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <iostream>
#include "FRSAPI.h"
//save file
void save_file(string path_m,string path_n,float score)
{
FILE *fp = NULL;
char word[1000];
memset(word,'\0',sizeof(word));
if((fp=fopen("score.txt","w+"))==NULL)
{
cout<<"save scorefail."<<endl;
exit(0);
}
sprintf(word,"%s %s%f",(path_m).c_str(),(path_n).c_str(),score);
fputs(word,fp);//文本
//fwrite(word,sizeof(word),1,fp);//二进制
fclose(fp);
cout<<"save scoresuccessed."<<endl;
}
int main()
{
string it1 ="/usr/local/src/NeoFRS2/Releasev1.0/sample/images/Photo1.jpg";
string it2 ="/usr/local/src/NeoFRS2/Releasev1.0/sample/images/Photo2.jpg";
float fScore = 1.0;
save_file(it1,it2,fScore);
}
#include<stdio.h>
#include<stdlib.h>
void read()
{
char word[1000];
char ch;
FILE *fp=NULL;
if((fp=fopen("score.txt","r+"))==NULL)
{
printf("read filefailed\n");
exit(0);
}
ch=fgetc(fp);
if(ch==EOF)
{
exit(0);
}
rewind(fp);
while(!feof(fp))
{
fgets(word,sizeof(word),fp);
fread(word,sizeof(word),1,fp);
printf("word :%s\n",word);
}
fclose(fp);
}
int main()
{
read();
}
- code 文件的保存、读取
- 文件的读取和保存
- 文件的保存和读取
- 文件的保存和读取
- 文件的保存及读取
- 保存、读取CFont到文件的解决方案
- Propertes文件的读取和保存
- Android----文件的保存与读取
- Android---02---文件的保存与读取
- 实例教程三:文件的保存与读取
- 读取保存密码的ini文件
- 文件保存和读取的问题
- android文件的保存与读取
- android---文件的保存与读取
- Java属性文件的读取和保存
- json文件的读取与保存
- Android文件的读取与保存
- BMP文件的读取和保存
- 学习maven的各种问题
- c语言感想
- code 提取字符串中的数字
- V$LATCH
- hdu--1007(分治求二维最近点对)
- code 文件的保存、读取
- WinPcap Pcap_findalldevs_ex() pcap_if
- 解析:TypedArray 为什么需要调用recycle()
- ios runtime 动态注册一个新类 增加一个方法
- Android使用系统打电话
- 装载问题
- LeetCode 112:Path Sum
- iOS开发之设计模式(一)
- PHP Socket请求类