[英]header for fopen visual studio 2015 community edition
As per MSDN: https://msdn.microsoft.com/en-us/library/yeby3zcb.aspx 根据MSDN: https : //msdn.microsoft.com/zh-CN/library/yeby3zcb.aspx
for "fopen" I need to include required header : <stdio.h>
对于“打开”,我需要包括必需的标头: <stdio.h>
However, my below code gives error: "identifier fopen is unidentified" 但是,我的以下代码给出了错误:“ identifier fopen is notidentified”
#include "stdafx.h"
#include<cstdio>
#include<cstdlib>
int main()
{
char * buffer = NULL;
size_t size = 0;
FILE *fp = fopen("C:\Documents and Settings\psps.txt", "r");
return 0;
}
What should I include to perform file-related operation? 我应该包括什么以执行与文件相关的操作?
You could try including <stdio.h>
as you mentioned. 如您提到的,您可以尝试包含<stdio.h>
。 Or, you could include <cstdio>
as you're currently doing and then use std::fopen()
instead. 或者,您可以在当前操作中包含<cstdio>
,然后改为使用std::fopen()
。
When C++ headers wrap the standard library functions in the std
namespace. 当C ++标头将标准库函数包装在std
名称空间中时。
The other option is to include <fstream>
and learn your way around the C++ file streaming classes (see http://www.cplusplus.com/doc/tutorial/files/ ). 另一个选择是包括<fstream>
并学习C ++文件流类的方法(请参阅http://www.cplusplus.com/doc/tutorial/files/ )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.