Removing last character in C

Just set the last char to be ‘\0’:

str[strlen(str)-1] = '\0';

In C, \0 indicates a string ending.

Leave a Comment