Cout没有输出? [英] No output for cout?
本文介绍了Cout没有输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include<iostream>
#include<iomanip>
#include <math.h>
using namespace std;
int doIt(int a){
a=a/1000;
return a;
}
void main(){
int myfav= 23412;
cout<<"test: "+doIt(myfav);
cin.get();
}
只是想知道为什么我没有为此打印出来。
预先感谢。
just wondering why i am not getting a print out for this. Thanks in advance.
推荐答案
我想指出的很少。主函数 void main()
的第一个返回类型应为 int main()
。
There are few this i would like to point out. First return type of main function void main()
it should be int main()
.
请勿使用使用命名空间标准;
有关更多详细信息,请访问为什么使用命名空间std
Don't use using namespace std;
for more detail visit Why is "using namespace std" considered bad practice?
最后一个问题是您无法使用+将整数插入字符串,您必须提取运算符,即<$ c
Finally problem in your code you cannot insert an integer into to a string using +, you will have to extraction operator i.e. <<
again.
#include<iostream>
#include<iomanip>
#include <math.h>
//using namespace std;
int doIt(int a)
{
a=a/1000;
return a;
}
int main()
{
int myfav= 23412;
std::cout<<"test: "<<doIt(myfav)<<"\n";
std::cin.get();
return 0;
}
这篇关于Cout没有输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文