adplus-dvertising
frame-decoration

Question

Point out the error in the following program.
#include<stdio.h>
#include<string.h>

int main()
{
    char str1[] = "Learn through Compscibits\0.com",  str2[120];
    char *p;
    p = (char*) memccpy(str2, str1, 'i', strlen(str1));
    *p = '\0';
    printf("%s", str2);
    return 0;
}

a.

Error: in memccpy statement

b.

Error: invalid pointer conversion

c.

Error: invalid variable declaration

d.

No error and prints "Learn through Comp"

Answer: (d).No error and prints "Learn through Comp"

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Point out the error in the following program.

Similar Questions

Discover Related MCQs

Q. C preprocessor

Q. A preprocessor command

Q. Choose the correct statement.

I. The scope of a macro definition need not be the entire program.
II. The scope of a macro definition extends from the point of definition to the end of the file.
III. New line is a macro definition delimiter.
IV. A macro definition may go beyond a line.

Q. In which header file is the NULL macro defined ?

Q. Which standard library function will you use to find the last occurance of a character in a string in C?

Q. What is the purpose of fflush() function.

Q. Can you use the fprintf() to display the output on the screen?

Q. Which of the following are correct preprocessor directives in C?

1: #ifdef
2: #if
3: #elif
4: #undef

Q. Which of the following are correctly formed #define statements in C?

Q. In the following code, the P2 is Integer Pointer or Integer?
typedef int *ptr;
ptr p1, p2;

Q. In the following code what is 'P'?
typedef char *charp;
const charp P;

Q. Which header file should be included to use functions like malloc() and calloc()?

Q. What function should be used to free the memory allocated by calloc() ?

Q. Specify the 2 library functions to dynamically allocate memory?

Q. Which of the following statement is correct prototype of the malloc() function in c ?

Q. What is the return type of malloc() or calloc()?

Q. Which function is used to delete the allocated memory space?

Q. Among 4 header files, which should be included to use the memory allocation functions like malloc(), calloc(), realloc() and free()?

Q. Which of the following is/are true?

Q. Which languages necessarily need heap allocation in the run time environment?