William M. answered 12/23/19
College Professor of C++ with 7+ years of teaching experience
// In C and C++, single quotes are used for characters...
// and double quotes are used for strings
// Note: in Python and JavaScript, both single and double quotes
// are used for strings
#include <iostream>
#include <string>
int main(int argc, const char* argv[]) {
char c = 'A';
printf("c is: %c\n\n", c);
// and double quotes are used for strings
// C++ version
std::string std_string = "this is a standard string in C++...";
// C version
char c_string[] = "C type string, with a \'\\0\' at the end...\n";
std::cout << "print out both strings in C++...\n";
std::cout << "std_string is: \n\t" << std_string
<< " \n... and c_string is: \n\t" << c_string << "\n";
// You can get the c_string part of a std::string using c_str()
const char* pstd_string = std_string.c_str();
printf("Printing std_string through its c_str() method...\n\t%s\n\n",
pstd_string);
return 0;
}