Array of Strings in C programming
Array of Strings in C programming
Size of an array:
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
char s[MAX_NAME] = "Ashiq";
char* ss[] = {"ash", "che", "ashiq", "chester"};
int length = sizeof(ss)/sizeof(ss[0]);
int sizeofarray = sizeof(ss);
printf("length: %d\n", length);
printf("Size of array: %d\n", sizeofarray);
// The size of the [ss] array is 32
for(int i=0; i<length; i++){
printf("%s\n", ss[i]);
}
return 0;
}
Output:
length: 4
Size of array: 32
ash
che
ashiq
chester
Comments
Post a Comment