Using Visual C++ 2019

Sid Kraft 21 Reputation points
2020-09-08T16:15:13.577+00:00

Seems like Visual C++ 2019 has special codes that are not supported by the standard C++ command structures. For example, many tutorials on-line suggest that one can get input from a console by entering the command as follows:

Libraries #include <cstdio>
#include <iostream>
#include <string>
using namespace std;
char Indata;

.
.
.
getline(cin,Indata);

Produces a compiler error, says cannot find getline!

Additionally, are there any books that would explain the commands and arguments available for the Visual C++ 2019 system?

Your help will be appreciated, Thanks, Sid Kraft

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,584 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 9,346 Reputation points Microsoft Vendor
    2020-09-09T02:34:24.747+00:00

    Hi,

    There are two different getline() function:

    In the <iostream>, we could try to use the following code:

    char Indata[256];  
    std::cin.getline (Indata, sizeof (Indata));  
    

    In the <string>, we could try to use the following code:

    std::string Indata;  
    getline (std::cin, Indata);  
    

    For more details I suggest you could refer to the link: https://stackoverflow.com/questions/4872361/why-are-there-two-different-getline-functions-if-indeed-there-are

    Best Regards,

    Jeanine


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments