Hi everyone. I am trying to write a program that read the first name of the user, then the second name, and displays each name with its length under it, first aligned to the right, and then, to the left, but I am only being able to accomplish the latter. The code is the following:
Code:
#include <stdio.h>
#include <string.h>
int main (void)
{
char first[12];
char last[12];
printf("Type in yout first name:\n");
scanf("%s", first);
printf("Type in your last name:\n");
scanf("%s", last);
printf("%s %s\n", first, last);
//3rd printf in this line
printf("%s %s\n", first, last);
printf("%d\t %d\t\n", strlen(first), strlen(last));
return 0;
}
How should be the third printf, in order to make the alingment to the right? I tried the following line,
Code:
printf("\t%d \t%d\n", strlen(first), strlen(last));
but the alignment wasn't complete. Thanks in advance!