Within say OIer of the most simple program, I am afraid none other than non-Hello World, then this article on how to write a Hello World (beaten).
- The simplest type of implementation:
#include <iostream>
using namespace std;
int main(){
cout << "Hello World" << endl;\
cin.get();
return 0;
}
- When the user presses the button when the show Hello World, loosen disappeared.
#include <iostream>
#include <cstdio>
#include <conio.h>
using namespace std;
int main(){
while(1){
if(_kbhit()){
cout << "Hello World";
system("cls");
_getch();
}
}
return 0;
}
- Set the text color and size (need to install the graphics library)
#include <graphics.h>
#include <conio.h>
int main(){
initgraph(600,480);
settextcolor(RGB(2,134,219));
settextstyle(60, 0, _T("微软雅黑"));
outtextxy(180,200,_T("Hello World"));
_getch();
closegraph();
return 0;
}
Run shot:
- Let the computer says: Hello World
#include <windows.h>
#include <mmsystem.h>
#include <conio.h>
int main(){
mciSendString("open say.mp3 alias music",NULL,0,NULL);
mciSendString("play music repeat");
_getch();
return 0;
}
Run the above code needs to record a Hello World with audio recordings, and then put it in the program directory, named say.mp3 (be careful not to have two suffix)