Please consider the following code:
int main (int argc, char *argv[])
{
char s1[9] = "abcdefghi";
int length = sizeof(s1);
printf("Size of s1: %d\n", length);
rev1(s1);
}
void rev1(char *s)
{
int length = sizeof(s)
printf("Size of s: %d\n", length);
}
When I run this program I get
Size of s1: 9
Size of s: 4
It doesn't matter what size I use for the s1 array, I always get 4 for the array size in rev1. I don't understand why s isn't 9. Why is it 4?
Can someone help me out?
Thanks!
int main (int argc, char *argv[])
{
char s1[9] = "abcdefghi";
int length = sizeof(s1);
printf("Size of s1: %d\n", length);
rev1(s1);
}
void rev1(char *s)
{
int length = sizeof(s)
printf("Size of s: %d\n", length);
}
When I run this program I get
Size of s1: 9
Size of s: 4
It doesn't matter what size I use for the s1 array, I always get 4 for the array size in rev1. I don't understand why s isn't 9. Why is it 4?
Can someone help me out?
Thanks!