Get the last character of the string in C language

Get the last character of the string in C language

In C, you can use strlen to get the length of a string,
The subscript of the last character is length - 1

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[]) {

	char c[20] = {'l','a','u','t','t','u','r','i','!'};

	int len = strlen(c);
	printf("%c\n",c[len-1]);

	char* str = "lautturi";

	int len1 = strlen(str);
	printf("%c",str[len1-1]);

	return 0;
}
Sour‮l.www:ec‬autturi.com
Created Time:2017-08-29 09:57:46  Author:lautturi