Q:
How would you find the length of each string in the following Program?
main()
{
char *str[] = { "Frogs", "Do", "Not" , "Die" , "They" , "Croak!"};
printf ("%d%d", sizeof (str), sizeof (str[0]));
}
Answer
main()
{
char *str[] = { "Frogs", "Do", "Not", "Die." , "They", "Croak!" };
int i;
for ( i = 0;i<=5;i++)
printf ("\n%s%d", str[i], strlen( str[i]));
}
View answer
Workspace
Report Error
Discuss