1. Physical size array, assign the actual size of the array.
2. Logical size array, the actual size you use.
Here’s the sample code:
#include <stdio.h> int main() { char text[100]; //physical size of array. int i=0; printf("Enter any text:"); scanf("%s",text); //For string format specifier no need to use &, accept one word only. /*Uncomment below to accept multiple words until user press enter.*/ //scanf("%[^\n]s",text); while(text[i]!='\0') //\0 is the terminating character. { i++; } printf("Logical size is %d\n",i); return 0; }