1

so I am teachuing myself c++ and I came accross conio.h

and I usually had a problem with cin.get(), and sometimes I had to duplicate it to keep the cosole open...

code:

// ConsoleApplication2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <conio.h>


int _tmain(int argc, _TCHAR* argv[])
{
    std::cout << "Hi" ;
    _getch();
    return 0;
}

what is the significance behind the "_" part of "_getch()"?

  • 2
    For a long and technical answer, [see this one](http://stackoverflow.com/a/228797/440558). – Some programmer dude Jan 13 '14 at 13:58
  • possible duplicate of [What are the rules about using an underscore in a C++ identifier?](http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier) – Charity Leschinski Jan 13 '14 at 14:10
  • This doesn't seem like a duplicate. The OP is asking why the CRT function have a different name (with underscore) – egur Jan 13 '14 at 14:37

2 Answers2

0

For a long and technical answer, see this one. – Joachim Pileborg

https://stackoverflow.com/a/228797/440558

Community
  • 1
  • 1
0

According to MSDN, Microsoft decided to move to the ISO C++ standard in VS2005.
They deprecated the POSIX names (e.g. getch) in favor of the ISO names (_getch).

You can use the POSIX names in VS by declaring this before the first header include:

#define _CRT_NONSTDC_NO_DEPRECATE
egur
  • 7,830
  • 2
  • 27
  • 47