为什么这段代码无法读取Blender的.obj文件?
Why does this code fail to read Blender's .obj file?
嗨,我正试图读取使用Blender创建的Wavefront文件。我把这个文件的副本放到了解决方案资源管理器中。当我第一次尝试编译时,我得到了以下消息:
致命错误LNK1107:无效或损坏的文件:不能在0x读取…
似乎编译器混淆了Blender的。obj文件与其他格式,也使用。obj结尾。解决方案是在其属性中将该文件从构建过程中排除。
现在应用程序确实编译了,但是没有显示我期望的数据。不确定这是否是代码问题。
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <fstream>
#include <string>
using namespace std;
void ReadPrintFile(string _fileName)
{
std::string line;
std::ifstream fileStream (_fileName);
if (fileStream.is_open())
{
while (getline(fileStream,line))
{
cout << line << 'n';
}
fileStream.close();
}
else
{
cout << "Unable to read file";
}
}
int _tmain(int argc, _TCHAR* argv[])
{
ReadPrintFile("Drone.obj");
std::cin.get();
return 0;
}
代码没有跳转到else语句。文件流似乎是空的,我直接转发到cin.get();
语句。我知道有很多关于如何在c++中解析。obj的教程,但我想了解。
诀窍不是将文件复制到解决方案资源管理器中,而是复制到项目文件夹中。
相关文章:
- 理解boost::asio-async_read在无需读取内容时的行为
- 使用新行和不使用新行读取文件
- 读取文件并输入到矢量中
- 用c++从输入文件中读取另一行
- 读取文件的最后一行并输入到链接列表时出错
- 在进程中对同一管道进行读取和写入时C++管道出现问题
- 无法找到/读取配置文件.conf-FileIOException
- 如何使用Luacneneneba API正确读取字符串和表参数
- C++将文本文件中的数据读取到结构数组中
- 正在将csv文件读取为双精度矢量
- 为什么 sscanf 无法从一个字符串中读取uint64_t和字符?
- 为什么在读取文件大小时文件IO速度会发生变化
- 正在读取二进制文件(is_open)
- 如何在c++中从文本文件中逐行读取整数
- SSH通过/sbin/SSH无法读取RSA密钥文件(从控制台运行)
- 独立读取-修改-写入顺序
- 从文本文件中读取时钟时间和事件时间并进行处理
- 如何从文本文件中读取值和数组
- 为什么文件名被设置为一个点,而不是在读取矢量中的文件名时
- 为什么这段代码无法读取Blender的.obj文件?