What will be result of the following program?
void myalloc(char *x, int n)
{
x= (char *)malloc(n*sizeof(char));
memset(x,\0,n*sizeof(char));
}
main()
{
char *g="String";
myalloc(g,20);
strcpy(g,"Oldstring");
printf("The string is %s",g);
}
a) The string is : String
b) Run time error/Core dump
c) The string is : Oldstring
d) Syntax error during compilation
e) None of these
Post New Answer View All Answers
What does %d do in c?
Can we declare a function inside a function in c?
write a program to copy the string using switch case?
How many identifiers are there in c?
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
What are the different types of pointers used in c language?
In c programming language, how many parameters can be passed to a function ?
Is that possible to add pointers to each other?
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays
What is the difference between local variable and global variable in c?
What is function definition in c?
What is volatile keyword in c?
What is the difference between fread and fwrite function?
What is a function simple definition?
Explain how can you determine the size of an allocated portion of memory?