Top

Strings

21.

which of the following function returns a pointer to the located string or a null pointer if string is not found.

Answer: B

The strstr() function is used to return a pointer to the located string, or if string is not found a null pointer is returned.

Enter details here

22.

What will be the output of the program ?

#include

int main()
{
    printf(5+"Good Morning\n");
    return 0;
}

 

Answer: D

No answer description available for this question.

Enter details here

23.

What will be the output of the program ?

#include
#include

int main()
{
    char str1[20] = "Hello", str2[20] = " World";
    printf("%s\n", strcpy(str2, strcat(str1, str2)));
    return 0;
}

 

Answer: C

No answer description available for this question.

Enter details here

24.

Which of the following is the right syntax to copy n characters from the object pointed to by s2 into the object pointed to by s1?

Answer: A

The memcpy() function copies n characters from the object pointed to by s2 into the object pointed to by s1. If copying takes place between objects that overlap, the behavior is undefined.

Enter details here

25.

The library function used to find the last occurrence of a character in a string is

Answer: C

No answer description available for this question.

Enter details here

Answer: B

The given code char *strchr(ch, c) return pointer to first occurrence of c in ch or NULL if not present.

Enter details here

27.

If the size of pointer is 32 bits What will be the output of the program ?

#include

int main()
{
    char a[] = "Visual C++";
    char *b = "Visual C++";
    printf("%d, %d\n", sizeof(a), sizeof(b));
    printf("%d, %d", sizeof(*a), sizeof(*b));
    return 0;
}

 

Answer: C

No answer description available for this question.

Enter details here

28.

What will the given C code do?

int memcmp(const void *str1, const void *str2, size_t n)

 

Answer: A

In the C library function int memcmp(const void *str1, const void *str2, size_t n)) is used to compare the first n bytes of memory area str1 and memory area str2.

Enter details here

29.

Predict the output of the following program:

#include  
int main() 
{ 
    char str[] = "%d %c", arr[] = "GeeksQuiz"; 
    printf(str, 0[arr], 2[arr + 3]); 
    return 0; 
} 

 

Answer: C

No answer description available for this question.
 

Enter details here

Answer: A

There are two groups of string functions declared under the header . The first have names beginning with str and second have names beginning with mem.

Enter details here

Loading…
Tags: Strings Questions and Answers || Strings MCQ Questions and Answers || Strings GK Questions and Answers || Strings GK MCQ Questions || Strings Multiple Choice Questions and Answers || Strings GK || GK on Strings || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming