Learning by doing: Reading books and trying to understand the (code) examples
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
567 B

  1. #include <stdio.h>
  2. #include <string.h>
  3. int main (void) {
  4. char first_name[21];
  5. char last_name[21];
  6. printf("Give your first name: ");
  7. scanf("%20s", first_name);
  8. printf("Give your last name: ");
  9. scanf("%20s", last_name);
  10. printf("%s %s\n", first_name, last_name);
  11. printf("%*lu %*lu\n", (int)strlen(first_name), strlen(first_name), (int)strlen(last_name), strlen(last_name));
  12. printf("%s %s\n", first_name, last_name);
  13. printf("%-*lu %-*lu\n", (int)strlen(first_name), strlen(first_name), (int)strlen(last_name), strlen(last_name));
  14. return 0;
  15. }