c++cout怎么不能输出?

#include <iostream.h>

void main()

{

char cl='A';

cout<<'w';

cout<<cl<<endl;

cout<<"this is a test."<<endl;

cout<<"----------"<<endl;

}

这样能输出
W A
this is a test
----------
吗?如果要输出
W A
this is a test
----------
要怎么写?
回答请写上谢了

第1个回答  推荐于2017-10-01
这是因为你同时用iostream和stdio两种输入输出标准导致的,你应该只用一个,要么用C的,要么用C++的。
如:
//#include <iostream.h>
#include <stdio.h>
struct person // 结构定义
{
char name[10];
};
person allone[6];
void main()
{
int i;
for(i = 0;i < 6;i++) // 输入数据
{
printf("%d name:",i); //(1)
gets(allone[i].name); //(2)
printf("\n");
}
}
第2个回答  推荐于2017-09-14
你的不能输出你想要的结果

使用我这改后的代码
#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
char cl = 'A';
cout << 'W' << ' ';
cout << cl << endl;
cout << "this is a test." << endl;
cout << "----------" << endl;

return 0;
}

你的之所以不行
是因为 你的输出是
wA
this is a test
----------本回答被提问者采纳
第3个回答  2006-12-19
现在输出的是
wA
this is a test.
----------

要完全一致的?
跟原来结果的主要区别:w是大写;W和A间有空格;test后面没有.

程序:
#include <iostream.h>

void main()

{

char cl='A';

cout<<"W ";

cout<<cl<<endl;

cout<<"this is a test"<<endl;

cout<<"----------"<<endl;

}

结果:
W A
this is a test
----------
第4个回答  2006-12-22
在#include<iostream>后面加上using namespace std;应该就可以了
如果没有此语句cout语句就不好使
相似回答