Removing first and last character of a string in C
In this post we will give you information about Removing first and last character of a string in C. Hear we will give you detail about Removing first and last character of a string in CAnd how to use it also give you demo for it if it is necessary.
we are going to learn about how to remove the first and last character of a string in C.
Consider, we have the following string.
char color[5] = "green";
Now, we want to remove the first character g and the last character n from the above string.
Removing the first and last character
To remove the first and last character of a string, we can use the following syntax in C.
Here is an example:
#include <stdio.h>#include <string.h>int main() { char color[5] = "green"; char *result = color+1; // removes first character result[strlen(result)-1] = '