WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c
file management?

Answer Posted / smitha

Malloc:
1. Takes only 1 argument- the size of the memory block to
be allocated.
2. Allocates memory as a single contiguous block.
3. Will fail if a single contiguous memory block of
required size is not available.

Calloc:
1. Takes two arguments - the number of memory blocks needed
and the size of each memory block.
2. It may or may not allocate a single contiguous block,
thus will not fail if a single contiguous memory block
of required size is not available.
3. Initialises the memory blocks to 0.

Is This Answer Correct ?    17 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is c object oriented?

528


Difference between constant pointer and pointer to a constant.

599


Why do we use c for the speed of light?

597


What is the difference between procedural and functional programming?

508


What is the difference between c and python?

571






How can I change their mode to binary?

680


a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

705


Write a program to reverse a string.

625


What is the explanation for cyclic nature of data types in c?

631


Write a program to print fibonacci series without using recursion?

592


if p is a string contained in a string?

1394


Explain what are reserved words?

625


What does the characters “r” and “w” mean when writing programs that will make use of files?

839


Write a C program linear.c that creates a sequence of processes with a given length. By sequence it is meant that each created process has exactly one child. Let's look at some example outputs for the program. Here the entire process sequence consists of process 18181: Sara@dell:~/OSSS$ ./linear 1 Creating process sequence of length 1. 18181 begins the sequence. An example for a sequence of length three: Sara@dell:~/OSSS$ ./linear 3 Creating process sequence of length 3. 18233 begins the sequence. 18234 is child of 18233 18235 is child of 18234 ........ this is coad .... BUt i could not compleate it .....:( #include #include #include #include int main(int argc, char *argv[]) { int N; pid_t pid; int cont; if (argc != 2) { printf("Wrong number of command-line parameters!\n"); return 1; } N = atoi(argv[1]); printf("Creating process sequence of length %d.\n",N); printf("%d begins the sequence.\n",getpid()); /* What I have to do next ?????? */ }

1608


#include #include struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

5164