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
Is c object oriented?
Difference between constant pointer and pointer to a constant.
Why do we use c for the speed of light?
What is the difference between procedural and functional programming?
What is the difference between c and python?
How can I change their mode to binary?
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
Write a program to reverse a string.
What is the explanation for cyclic nature of data types in c?
Write a program to print fibonacci series without using recursion?
if p is a string contained in a string?
Explain what are reserved words?
What does the characters “r” and “w” mean when writing programs that will make use of files?
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