The code at "What I have tried" is correct.
It is a common C/C++ beginners problem to understand the relation of pointers and arrays.
But it is covered by any C/C++ books and tutorials (search the web for something like "array vs pointer").
See for example the section "Pointers and Arrays" at
C Class - Arrays, String Constants and Pointers[
^].
In your case you have the function parameter
char *strings
. That means
strings
is a pointer to
char
values. Using the
Dereference operator - Wikipedia[
^], you would access the first character of the string:
char first_char = *strings;
That can be also done with the array access
[]
operator:
char first_char = strings[0];
So using
char c = *strings[0];
is the same as
char c = **strings;
and both result in a compilation error because the above would be only valid when
strings
is of type
char **
(pointer to pointer to
char
).