Ani*_*oel 0 c++ compiler-construction visual-studio
我在这段代码中遇到编译错误
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
void main(int argc,char *argv[])
{
int i;
for(i = 0;i<10;i++)
fprintf(cout,"%d\n",i);
fprintf(cout,"abc:\n");
string s;
cin>>s;
if(s == "resume") {
for(i = 0;i<10;i++)
fprintf(cout,"%d\n",i);
}
}
Run Code Online (Sandbox Code Playgroud)
Microsoft(R)32位C/C++优化编译器版本15.00.21022.08(适用于80x86)版权所有(C)Microsoft Corporation.版权所有.
try.cpp C:\ Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342):警告C 4530:使用了C++异常处理程序,但未启用展开语义.指定/ EHsc
try.cpp(9):错误C2664:'fprintf':无法将参数1从'std :: ostr eam'转换为'FILE*'没有可用于执行此转换的用户定义转换运算符,或者运算符不能叫做
try.cpp(10):错误C2664:'fprintf':无法将参数1从'std :: ost ream'转换为'FILE*'没有可用于执行此转换的用户定义转换运算符,或者运算符不能叫做
try.cpp(16):错误C2664:'fprintf':无法将参数1从'std :: ost ream'转换为'FILE*'没有可用于执行此转换的用户定义转换运算符,或者运算符不能叫做
怎么了?
小智 6
您正在混合使用C++和C输出样式.将您的fprintf更改为:
cout << "value is: " << i << "\n";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2233 次 |
| 最近记录: |