C read string and char array with spaces

The method that should be used when reading input with spaces:

<1> String     string :

        #include <string>

        string a;

       getline (cin, a);


<2>Character array   char :

      The first:

         #include <cstdio>

         char[10] a;

         gets(a);

      The second:

         #include <iostream>

         char[10] a;

         cin.getline (a, 10);

        //cin.get(a,10);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325942354&siteId=291194637