[c]Using arrays – 2

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.*/
    while(text[i]!='\0') //\0 is the terminating character.
    printf("Logical size is %d\n",i);
    return 0;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s