C++: Print only one char
- by Martijn Courteaux
Hi,
When I read one char* from std::cin and I want to write it to std::cout, it prints until it finds a \0 in memory. So what did was:
char c;
cin >> c;
char* pChar = &c;
pChar++;
*pChar = '\0';
println(&c); // My own method: void println(char * str) { cout << str << endl; }
But I don't think this is a safe action.
Is there a safer way to do this?