#include<iostream.h> #include<stdio.h>
main() { cout<<"hello "; printf("how are you "); }
怎么先是输出 how are you 再输出hello
#include<iostream.h> #include<stdio.h>
main() { cout<<"hello "; printf("how are you "); }
怎么先是输出 how are you 再输出hello
我个人认为,这是编译器的问题,上面这段代码我在Dev 下也试验了一下,没问题。
另外,我对你的程序的头文件设置稍作变动,在VC下也一样没问题。我的建议是尽量采用新的标准库的书写方法。
变动后的代码:
#include<iostream> #include<cstdio> #include<cstdlib> using namespace std;
int main() { cout<<"hello "; printf("how are you "); system("pause"); return 0; }
你是用什么编译器的?这个程序:
#include <iostream> #include <cstdio> using namespace std;
int main(void) { cout<<"Hello, "; printf("world!\n"); system("PAUSE"); }
我在Dev-C++, VC2003, Borland C++ 5.5中结果都是:Hello, world! 没有错误啊
wonderfulday ,
我想你误会了,我的意思是,用
#include <iostream>
using namespace std;
不要写成:
#include <iostream.h>
前一种是符合新的标准的书写方法
#include <iostream.h> #include <stdio.h>int main() { cout<<\"hello \"<<endl; //后面建议加上endl,作用是清空缓冲区,使内容直接输出! printf(\"how are you \"); getchar(); //暂停,不然来不及看窗口显示的东西 return 0; }