Code:

#include <iostream> #include <conio.h> using namespace std; int main () { cout << "Hello world!!!\n"; _getch(); return 0; } 

Tell me, please, how to run the program in Microoft Visual Studio C ++ 2010, Express edition. OS Windows XP Professional 2008 Edition, Service Pack 3.

It gives the following error:

 ------ ΠŸΠΎΡΡ‚Ρ€ΠΎΠ΅Π½ΠΈΠ΅ Π½Π°Ρ‡Π°Ρ‚ΠΎ: ΠΏΡ€ΠΎΠ΅ΠΊΡ‚: 1, ΠšΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΡ: Debug Win32 ------ 1.cpp c:\documents and settings\1\ΠΌΠΎΠΈ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Ρ‹\visual studio 2010\projects\11\11\11.cpp(3): warning C4627: #include <iostream>: ΠΏΡ€ΠΎΠΏΡƒΡ‰Π΅Π½ ΠΏΡ€ΠΈ поискС использования ΠΏΡ€Π΅Π΄ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡ€ΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠ° Π”ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Ρ‹ Π² "StdAfx.h" ΠΈΠ»ΠΈ пСрСстройка ΠΏΡ€Π΅Π΄ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡ€ΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠ° c:\documents and settings\1\ΠΌΠΎΠΈ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Ρ‹\visual studio 2010\projects\11\11\11.cpp(4): warning C4627: #include <conio.h>: ΠΏΡ€ΠΎΠΏΡƒΡ‰Π΅Π½ ΠΏΡ€ΠΈ поискС использования ΠΏΡ€Π΅Π΄ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡ€ΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠ° Π”ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Ρ‹ Π² "StdAfx.h" ΠΈΠ»ΠΈ пСрСстройка ΠΏΡ€Π΅Π΄ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡ€ΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠ° c:\documents and settings\1\ΠΌΠΎΠΈ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Ρ‹\visual studio 2010\projects\11\11\11.cpp(14): fatal error C1010: Π½Π΅ΠΏΡ€Π΅Π΄Π²ΠΈΠ΄Π΅Π½Π½Ρ‹ΠΉ ΠΊΠΎΠ½Π΅Ρ† Ρ„Π°ΠΉΠ»Π° Π²ΠΎ врСмя поиска ΠΏΡ€Π΅Π΄ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡ€ΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠ°. Π’ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ, Π²Ρ‹ Π·Π°Π±Ρ‹Π»ΠΈ Π΄ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Ρƒ "#include "StdAfx.h"" Π² источник. ========== ΠŸΠΎΡΡ‚Ρ€ΠΎΠ΅Π½ΠΈΠ΅: ΡƒΡΠΏΠ΅ΡˆΠ½ΠΎ: 0, с ошибками: 1, Π±Π΅Π· ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΉ: 0, ΠΏΡ€ΠΎΠΏΡƒΡ‰Π΅Π½ΠΎ: 0 -========= 
  • one
    When creating a project, choose β€œcreate an empty project” and not with additional headers. Or add #include "StdAfx.h" to the current file, if I'm not mistaken. - nullptr

3 answers 3

conio.h will not work in visual studio (at least in new versions).

conio.h is an outdated library, which is already in few places.

Use the system ("PAUSE") function to view the result.

 #include <iostream> using namespace std; int main () { cout << "Hello world!!!\n"; system("PAUSE"); return 0; } 

With this problem should not arise.

  • one
    No system ("pause") is needed. In the studio there is Ctrl + F5, so that the window does not close. - dzhioev
  • I press Ctrl + F5, the message is displayed: "to continue, press any key ...". after clicking the window closes. i.e. "hello world" is not displayed. How to achieve that "hello world" was displayed? - siner
  • Why is this happening ???? - siner
  • Tell me please! The second day I can not start the simplest program ((( - siner
  • happened. Thanks a lot, everyone!!! - siner

I have not written in VS for a long time, but for the last time in VS 2005

Well, actually there he was sure to require a connection.

 #include "StdAfx.h" 

Here, too, the compiler asks for the connection of this file.

At the beginning you need to add this line and all. otherwise, the program should work as planned.

  • When creating a project, you could tick the Empty Project. Then stdafx.h is not needed. - Janycz

Try this:

 #include "StdAfx.h" #include <Windows.h> //(для system("PAUSE");) #include <iostream> using namespace std; int main () { cout << "Hello world!!!\n"; while(1){ system("PAUSE"); } return 0; } 
  • message: "to continue, press any key ...". after clicking the window closes. - siner
  • Well, yes, and you want it to not close at all? then add while (1) {} to system ("PAUSE"); and system ("PAUSE"); clean up. The program will loop and close only by pressing on the "X" - Alerr
  • the fact is that "hello world" is not displayed! immediately writes "to continue, press any key ..." - siner
  • uh, is not displayed? strange ... Try printf ("HW! \ n"); instead of cout << "Hello world !!! \ n"; - Alerr
  • well, the result is the same anyway ( - siner