```
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

main()
{
    char str[5]={'\0'};
    printf("Initial length before passing = %ld\n",strlen(str));
    input(str);
    printf("Received string = %s\n",str);
    printf("Length after getting input(calling function) = %ld\n",sizeof(str));
}

input(char * buffer)
{
    puts("Enter something: ");
    printf("Initial length after passing = %ld\n",strlen(buffer));

    if ( fgets(buffer, sizeof(buffer), stdin) == NULL )
        return -1;
    else
    {
        printf("Length after getting input(called function)= %ld\n",strlen(buffer));
        return 0;
    }
}

```

### Output 1

```
Initial length before passing = 0
Enter something: 
Initial length after passing = 0
hello
Length after getting input(called function)= 6
Received string = hello

Length after getting input(calling function) = 5

```

### Output 2

```
Initial length before passing = 0
Enter something: 
Initial length after passing = 0
helloooooo
Length after getting input(called function)= 7
Received string = hellooo
Length after getting input(calling function) = 5

```

Why is it printing different lengths in when I gave different input?

1. In output 1 & 2 why the initial length is 6 when I allocated space for only 5 characters?
2. Why is the length of string different before passing and after passing in both output 1 and output 2?
3. In output 2 why "Length after getting input(called function)= 7" when I allocated only less space?