I am trying to slice the last four characters off a character array, and I tried the method that Python uses without success;
char *charone = (char*)("I need the last four")
char *chartwo = charone[-4:]
cout << chartwo << endl;
I would want this code to return:
four
But C/C++ doesn’t seem to be that easy…
Where could I find a simple alternative that will return the last four characters of one character array into another character array?
Try:
In C++, you can replace that with:
The code uses a special property of C strings that only works for chopping off the beginning of a string.