Check The Programming Section
In C programming the string.h header file does not offers any such library fucntion which can return the character of any location or index of a given string. To retrieve a character we can use the index with a pair square brackets([ ]). In C programming, array does not supports boundary checking condition before accessing that memory location. So before accessing any location to get a character we need to confirm the location is less than the length of the string or not. The required code is given below:
getLength() - returns the length of the string
charAt() - first checks the given index is less than the length of the string or not. If yes then return the ASCII value of that character. Else return -1.
Inside the main(), fgets() is used to take input a string. After calling charAt(), the return value need to be check. If the return value is -1, it means the location is out of bounday of the array. Else the character at given location will be printed.