How can I remove the last char from a char* variable? Is there any substring function that I can use with char*?
This is a discussion on Removing last char from char* within the C++ Programming forums, part of the General Programming Boards category; How can I remove the last char from a char* variable? Is there any substring function that I can use ...
How can I remove the last char from a char* variable? Is there any substring function that I can use with char*?
Code:#include <iostream> #include <string> using namespace std; char text[] = "some text"; text[strlen(text)-1] = '\0'; cout << text; Output: some tex