निम्न त्रुटि के साथ विफल हो जाता है prog.cpp:5:13: error: invalid conversion from ‘char’ to ‘const char*’
int main()
{
char d = 'd';
std::string y("Hello worl");
y.append(d); // Line 5 - this fails
std::cout << y;
return 0;
}
मैंने भी कोशिश की, निम्नलिखित, जो संकलित करता है, लेकिन रनटाइम पर बेतरतीब ढंग से व्यवहार करता है:
int main()
{
char d[1] = { 'd' };
std::string y("Hello worl");
y.append(d);
std::cout << y;
return 0;
}
इस गूंगे प्रश्न के लिए क्षमा करें, लेकिन मैंने Google के चारों ओर खोज की है, जो मैं देख सकता था, वह है "char array to char ptr", "char ptr to char array", आदि।