Huy.
I am trying to write a simple program to get the size of two strings at run time. I mean I let the user enter the strings and then I wanna use the sizeof operator to compare the sizes of the two strings.

Heres my code:
Code:
#include <stdio.h>

int main()
{
	char string1[],string2[];
	size_t size1,size2;
	printf("enter string1\n");
	gets(string1);
	printf("enter string2\n");
	gets(string2);
	size1 = sizeof(string1);
	size2 = sizeof(string2);
	printf("the size of string1 is %d\n",size1);
	printf("the size of string2 is %d\n",size2);
	return 0;
}
and it gives me the following errors:

Compiling...
strng_copy.c
D:\VC++\chap7_pointers\str_copy\strng_copy.c(5) : error C2133: 'string1' : unknown size
D:\VC++\chap7_pointers\str_copy\strng_copy.c(5) : error C2133: 'string2' : unknown size
D:\VC++\chap7_pointers\str_copy\strng_copy.c(11) : warning C4034: sizeof returns 0
D:\VC++\chap7_pointers\str_copy\strng_copy.c(12) : warning C4034: sizeof returns 0
Error executing cl.exe.

strng_copy.obj - 2 error(s), 2 warning(s)

How does one go about telling the compiler that the size(s) would be known only at run time and not at compile time?

Is there any other way to go about it?

Hoping to hear from you

Best Regards,
Aijaz Baig.