added string2hex prog (usefull for wep key)
[my-code/beginners.git] / length.c
1 /*  Type something ... and I tell you it's length!   */
2 #include <string.h>
3 #include <stdio.h>
4
5 char first[100];     /* string for firstname  */
6 char last[100];      /* etc. */
7 char full[200];      /* string for the full name */
8 char line[4];        /* string for age  */
9 int age;             /* variable for Age  */
10
11 int main()
12 {
13   printf(" -----------------------------------------------------------\n");
14   printf("Yoh dude, ready to let me count...:\n");
15
16   printf("Enter first name: ");
17   fgets(first, sizeof(first), stdin);
18   first[strlen(first) - 1] = '\0';
19
20   printf("now the last name : ");
21   fgets(last, sizeof(last), stdin);
22   last[strlen(last) - 1] = '\0';
23
24   printf("...and your age: ");
25   fgets(line, sizeof(line), stdin);
26   sscanf(line ,"%d" ,&age);
27
28     strcpy(full, first);
29     strcat(full, " ");
30     strcat(full, last);
31
32  printf("%s got %d cHaRaCtErS man!\n", full, strlen(first) + strlen(last) - 2);        /* -- \0 must not be counted -- */
33  printf("...and you are %d years old!\n",age );
34   return(0);
35 }
36
37