获得一个已打开的文本文件(openfile.txt),并把里面的内容输出到新的文本文件中(new.txt)
#include <afx.h>
#include <iostream.h>
void main()
{
// 读文件路径
CString filePathFrom;
filePathFrom.Format("%s", "E:\\openfile.txt");
// 读取文件
CFile filefrom;
char buf[1024];
memset(buf, 0x00, 1024);
filefrom.Open(filePathFrom, CFile::modeRead, NULL);
filefrom.Read(buf, 1024);
filefrom.Close();
// 写文件路径
CString filePathto;
filePathto.Format("%s","E:\\new.txt");
// 定入文件
CFile fileto;
fileto.Open(filePathto, CFile::modeWrite, NULL);
fileto.Write(buf, 1024);
fileto.Close();
// 清理
}
偶不明白这是什么问题?
程序报错是:
--------------------Configuration: 111 - Win32 Debug--------------------
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/111.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
另外,“清理”工作需要做哪些操作?
#include <iostream.h>
void main()
{
// 读文件路径
CString filePathFrom;
filePathFrom.Format("%s", "E:\\openfile.txt");
// 读取文件
CFile filefrom;
char buf[1024];
memset(buf, 0x00, 1024);
filefrom.Open(filePathFrom, CFile::modeRead, NULL);
filefrom.Read(buf, 1024);
filefrom.Close();
// 写文件路径
CString filePathto;
filePathto.Format("%s","E:\\new.txt");
// 定入文件
CFile fileto;
fileto.Open(filePathto, CFile::modeWrite, NULL);
fileto.Write(buf, 1024);
fileto.Close();
// 清理
}
偶不明白这是什么问题?
程序报错是:
--------------------Configuration: 111 - Win32 Debug--------------------
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/111.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
另外,“清理”工作需要做哪些操作?
...全文
相关推荐
qt入门程序——读取txt文件
qt入门级的程序,读取txt文件代码。通过QFileDialog选择文件路径及文件名,将文件内容读入QTextStream,定义QString变量line来一行行读取文件内容,最后用label或textbrowser显示。
文本操作方法OpenFile and operateFile
文本操作方法OpenFile and operateFile is very usful if you want to study C#
文本文件的打开、保存以及字体的设置
数据库中用C#实现的文本文件的打开、保存与字体大小、颜色等的设置!用RichTextBox组件实现。
C++用类读取和处理TXT文件数据
用C++类读取TXT文件数据,一行一个条数据,每条数据有3个不同数据字段,容器是用vector,字符串类型用string,指针的处理都是用封装的处理,C++就是强大
c++文件输入输出
本文件中包含了C++语言中各种输入输出到文本文件函数的应用解析和实例。


