in Programming edited by
178 views
0 votes
0 votes

What is the output of this program?

#include <stdio.h>
#include <string.h>
int main()
{
    char string[] = "Hello";
    printf("%lu %lu", sizeof(string), strlen(string));
    return 0;
}
  1. $5 \ 6$
  2. $5 \ 5$
  3. $6 \ 5$
  4. $6 \ 6$
in Programming edited by
by
178 views

1 Answer

1 vote
1 vote
Best answer

C.  6 5

 

sizeof("Hello") = 6.

strlen("Hello") = 5. 

 

https://ideone.com/oi9ANE

edited by

3 Comments

i am confused with strlen() here mentioned strlen compute the number of character in the string ignoring the null character .but i saw a question on go( programming in c:gate 2004-23) where  null character is also included to count the lenth of string.
0
0
0
0
strlen() will return length as 6 and p[0]=s[6-0] will print nothing.
0
0
Answer:

Related questions