I'm trying to print the sizeof character strings. I understand that I get output of 15 because that is the size I indicated in my definitions. My question is, how can I make that value variable based on the input of first/last names?
Code:
#include <stdio.h>
#include <ctype.h>
#include <string.h>
char * caps ( char * );
void main ( void )
{
char first[15];
char last[15];
int number;
char * p1;
char * p2;
printf("Enter your first name ");
gets(first);
printf("Enter your last name ");
gets(last);
printf("The original names were %s and %s\n",first,last);
p1 = first;
p2 = last;
caps(p1);
caps(p2);
printf("The capitalized names are %s and %s\n",first,last);
printf("Your first name, has %d letters\n", sizeof (first));
}
char* caps ( char *in )
{
char * x;
x = in;
while (*x)
{
*x = toupper(*x);
x++;
}
return(in);
}
Thanks, Bunko