Try to understand this and you can do your program. Read about string.h and about the strlen fuction in any c book.
// This an example i found in one of my c books. Is this helps?
#include <string.h> /* provides strlen() prototype */
#define PRAISE "What a super marvelous name!"
printf("What's your name?\n");
printf("Hello, %s. %s\n", name, PRAISE);
printf("Your name of %d letters occupies %d memory cells.\n",
strlen(name), sizeof name);
printf("The phrase of praise has %d letters ",
printf("and occupies %d memory cells.\n", sizeof PRAISE);