【发布时间】:2012-06-06 05:02:24
【问题描述】:
根据示例代码https://developers.google.com/protocol-buffers/docs/cpptutorial,他们展示了如何解析二进制格式的原始文件。使用
tutorial::AddressBook address_book;
{
// Read the existing address book.
fstream input(argv[1], ios::in | ios::binary);
if (!address_book.ParseFromIstream(&input)) {
cerr << "Failed to parse address book." << endl;
return -1;
}
}
我尝试为我的文本格式的输入文件删除ios::binary,但在读取文件时仍然失败。我需要做什么才能读取文本格式的 proto 文件?
【问题讨论】:
标签: c++ input io protocol-buffers