Your final part is very wrong:
*
gets
is the wrong method to call: it should be
printf
* Parameters are separated by commas, not dots. Replace the "." with a comma:
gets("%s%s",firstname[0]. familyname[i]);
^
|
* The format string is wrong: you don't separate the output strings so the will be printed concatenated together:
SJohn
, not
S. John
as required by you homework assignment.
* "%s" prints a string: you pass it a character
firstname[0]
so that won't work:
Format Specifiers in C[
^]
* Again, "%s" prints a string: you pass it a character
familyname[i]
so that won't work either.
* Your loop is unnecessary, and unwanted: even corrected it will print the first character of the first name before each character of the family name!
*
str
is not used at all!
Stop and think about what you are trying to do: that code looks like it was thrown together without any real planning going on before hand, and that never helps.
This may help you:
How to Write Code to Solve a Problem, A Beginner's Guide[
^]