Top

Strings

1.

Is there any function declared as strstr()?

Answer: A

This function returns a pointer to the first occurrence in s1 of any of the entire sequence of characters specified in s2, or a null pointer if the sequence is not present in s1.
char *strstr(const char *s1, const char *s2)

Enter details here

2.

Which among the following is Copying function?

Answer: A

The memcpy() function is used to copy n characters from the object.
The code is void *memcpy(void *s1,const void *s2, size_t n).

Enter details here

3.

The ______ function appends not more than n characters.

Answer: C

The strncat() function appends not more than n characters from the array(s2) to the end of the string(s1).char *strncat(char *s1, const char *s2,size_t n);

Enter details here

4.

Which of the following function is used to find the first occurrence of a given string in another string?

Answer: C

No answer description available for this question.

Enter details here

5.

What will be the output of the following C code?

#include 
    int main()
    {
        char *str = "hello, world";
        char *str1 = "hello, world";
        if (strcmp(str, str1))
            printf("equal");
        else
            printf("unequal");
    }

 

Answer: B

No answer description available for this question.
 

Enter details here

6.

What will be the output of the program ?

#include

int main()
{
    static char mess[6][30] = {"Don't walk in front of me...", 
                               "I may not follow;", 
                               "Don't walk behind me...", 
                               "Just walk beside me...", 
                               "And be my friend." };

    printf("%c, %c\n", *(mess[2]+9), *(*(mess+2)+9));
    return 0;
}

 

Answer: B

No answer description available for this question.

Enter details here

7.

Which of the following function is more appropriate for reading in a multi-word string?

Answer: C

No answer description available for this question.

Enter details here

8.

Which pre-defined function returns a pointer to the last occurence of a character in a string?

Answer: B

No answer description available for this question.

Enter details here

9.

What will be the output of the following C code?

#include 
    int main()
    {
        char str[10] = "hello";
        char *p = strrchr(str, 'l');
        printf("%c\n", *(++p));
    }

 

Answer: B

No answer description available for this question.

Enter details here

Answer: B

The void *memset(s, c, n) places character c into first n characters of s, return s.

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