65,187
社区成员




extern "C" _declspec(dllexport) int FileCreate(char *filePath,char *fileContext);
extern "C" _declspec(dllexport) char* FileRead(char *filePath);
//创建文件 成功返回0 失败返回1
//filePath文件路径 比如c:/myfile.txt
//fileContext文件内容 比如 测试写入abc123
int FileCreate(char *filePath,char *fileContext)
{
}
//读取文件 成功返回文件内容 失败返回空字符串
//filePath文件路径 比如c:/myfile.txt
char* FileRead(char *filePath)
{
}
//创建文件 成功返回0 失败返回1
//filePath文件路径 比如c:/myfile.txt
//fileContext文件内容 比如 测试写入abc123
int FileCreate(char *filePath, char *fileContext)
{
FILE *fp;
errno_t err;
if((err = fopen_s(&fp, filePath, "w")) !=0 ) return 1;
fprintf(fp,fileContext);
fclose(fp);
fp = NULL;
return 0;
}
//读取文件 成功返回文件内容 失败返回空字符串
//filePath文件路径 比如c:/myfile.txt
char* FileRead(char *filePath)
{
FILE *fp;
errno_t err;
if((err = fopen_s(&fp, filePath, "r")) !=0 ) return "open error";
char text[256],end[MAX_PATH][MAX_PATH]={0};
while(!feof(fp))
{
fgets(text,sizeof(text),fp);
lstrcat(end[0],text);
end[0][strlen(end[0])]='\0';
lstrcat(end[0],"\n");
}
fclose(fp);
fp = NULL;
return *end;
}