Sunteți pe pagina 1din 20

madasamy

RE: what is he difference between malloc and calloc

malloc is memory allocationcalloc is memory release

Is this answer useful? Yes | No Overall Rating: -2


1 3

April 03, 2006 15:53:10


sanjay

RE: what is he difference between malloc and calloc

1:what is he difference between malloc and calloc

Is this answer useful? Yes | No Overall Rating: -2


0 2

April 06, 2006 03:00:54


Rajeev
RE: what is he difference between malloc and calloc

Syntax
#include <stdlib.h>
void *malloc (Size) void free (Pointer)
void *realloc (Pointer Size) void *calloc (NumberOfElements ElementSize )
Size
Specifies a number of bytes of memory.
Pointer
Points to the block of memory that was returned by the
NumberOfElements Specifies the number
of elements in the malloc or calloc subroutines. The Pointer parameter points
array. to the first (lowest) byte address of the block.
ElementSize Specifies the size of
each element in the
array.

Is this answer useful? Yes | No

May 02, 2006 05:30:31


parthiban_mcet

Member Since: May 2006 Contribution: 1

RE: what is he difference between malloc and calloc

malloc is dynamic memory allocation it allocates the memory and initialize garbage value.
calloc is similar to malloc but only difference is initialize zero

Is this answer useful? Yes | No Overall Rating: -N/A-


1 1

July 08, 2006 04:58:36


rajesh kanna

RE: what is the difference between malloc and calloc

malloc - create the memory space


calloc-calculate the memory space

Is this answer useful? Yes | No Overall Rating: -1


0 1

November 28, 2006 03:59:47


sharmila

RE: what is the difference between malloc and calloc

malloc- take one argument i.e(malloc(sizeof(int)*10) and allocate bytes of memory.


calloc-take two argument i.e(calloc(no.of.var size of each var) and allocate block of memory.

Is this answer useful? Yes | No Overall Rating: +2


2 0

December 09, 2006 03:39:26


gunasekarnp

Member Since: December 2006 Contribution:


2

malloc used for memory reduce

Is this answer useful? Yes | No Overall Rating: -1


0 1

December 09, 2006 03:40:30


gunasekarnp

Member Since: December 2006 Contribution:

RE: what is the difference between malloc and calloc

reduce the memory size

Is this answer useful? Yes | No Overall Rating: -1


0 1

January 12, 2007 00:35:46


Sharath
RE: what is the difference between malloc and calloc

1. malloc takes only the size of the memory block to be allocated as input parameter.
2. malloc allocates memory as a single contiguous block.
3. if a single contiguous block cannot be allocated then malloc would fail.

1. calloc takes two parameters: the number of memory blocks and the size of each block of
memory
2. calloc allocates memory which may/may not be contiguous.
3. all the memory blocks are initialized to 0.
4. it follows from point 2 that calloc will not fail if memory can beallocated in non-contiguous
blocks when a single contiguous blockcannot be allocated.

Is this answer useful? Yes | No Overall Rating: +2


2 0

February 16, 2007 13:28:49


fcawad_03

Member Since: October 2006 Contribution:

RE: what is the difference between malloc and calloc

malloc::::: Allocates memory requests size of bytes and returns a pointer to the Ist byte of
allocated space calloc:::::::: Allocates space for an array of elements initializes them to zero and
returns a pointer to the memory

Is this answer useful? Yes | No


Overall Rating: +1
1 0

Page 1 of « Fir
1 2> Last »
2 st

I also faced this Question!! Ran Answer Posted By


k
Re: what is the main difference between c and c++?

Answe c is not object oriented but c++ is 3 Richa


object oriented
r
#1
260
5
Is This Answer
Yes
Correct ? 241 No

Re: what is the main difference between c and c++?

Answe Actually c is a procedural 3 Rajeev Kumar


programming language which
r
cann't face the real world problem.
# 2 It has some drawback
like a global data is shared by all
function and if in a
large program it is find out
difficult that which function
uses which data.

On the other hand c++ is an object


oriented programming
language which eliminate some
pitfall of conventional or
procedural programming language. It
is a concept or
approach for designing a new
software. It is nothing to do
with any programming language
although a programming
language which support the oops
concept to make it easier
to implement.

This is the main different between


c and c++.

178
6
Is This Answer
Yes
Correct ? 227 No
Re: what is the main difference between c and c++?

Answe in c we use scanf function as 3 Chetna Chaudhari


standard input function,while
r
in c++ we use streame cin>> for
# 3 input.like this for output
in c we use printf function,while
in c++ we use cout<< as a
output function.

110
6
Is This Answer
Yes
Correct ? 409 No

Re: what is the main difference between c and c++?

Answe in c we use #include<stdio.h>as 2 Chetna


iclusion file,while in c++
r Chaudhari,jalgaon
we use #include<iostreame>as
# 4 inclusion file.

871
Is This Answer Yes
Correct ? 490 No

Re: what is the main difference between c and c++?

Answe In object oriented programming, the 4 Sumit Gupta ,


programmer can solve
r Bangalore
problems by breaking them down into
# 5 real-life objects (it
presented the programmer with an
opportunity to mirror real
life). What is an object? This
topic is dealt with
extensively in the chapter on
‘Objects and Classes’ but a
brief introduction is provided
here.

Consider the category of cars. All


cars have some common
features (for example all cars have
four wheels, an engine,
some body colour, seats etc.). Are
all cars the same? Of
course not. A Fiat and a Ford
aren’t the same but they are
called as cars in general. In this
example cars will form a
class and Ford (or Fiat) will be an
object.

For those people who know C


programming, it would be useful
to know the differences between C
and C++. Basically C++
includes everything present in C
but the use of some C
features is deprecated in C++.

*C does not have classes and


objects (C does not support
OOP)
*Structures in C cannot have
functions.
*C does not have namespaces
(namespaces are used to
avoid name collisions).
*The I/O functions are entirely
different in C and C++
(ex: printf( ), scanf( ) etc. are
part of the C language).
*You cannot overload a function
in C (i.e. you cannot
have 2 functions with the same name
in C).
*Better dynamic memory
management operators are
available in C++.
*C does not have reference
variables (in C++ reference
variables are used in functions).
*In C constants are defined as
macros (in C++ we can
make use of ‘const’ to declare a
constant).
*Inline functions are not
available in C.

816
Is This Answer Yes
Correct ? 106 No

Re: what is the main difference between c and c++?

Answe c is a topdown approach while c++ 2 Ketan


is bottom up approach
r
#6 821
Is This Answer Yes
Correct ? 142 No

Re: what is the main difference between c and c++?

Answe IN c-programe the main function 2 Satyajith Srinivas


could not return a value
r
but in the c++ the main function
# 7 shuld return a value

381
Is This Answer Yes
Correct ? 587 No

Re: what is the main difference between c and c++?

Answe The main Difference between C and 3 Jayasrinivas.dona


C++ is C is Object Based
r valli
program.that means in C also we
# 8 have Object based
Applications like Structures and
Unions.
C++ is Object Oriented Language
that means entire
application will be depending on
Objects only.
Uses of Object oriented Program is
Reusability,Increase the
effiency of the program and it
gives extra security like
Private data is also be there in C+
+.
C++ is the Advanced version of C.
In otherwords we say c++ supports
both Object based and
Object oriented Applications

449
Is This Answer Yes
Correct ? 104 No

Re: what is the main difference between c and c++?


Answe A function can be declared in C as 1 Krushna Priya
int fun();. This means
r Nath
that fun()is a function without any
# 9 argument or any number
of arguments.But in C++, this means
that the function with
no argument at all.

262
Is This Answer Yes
Correct ? 126 No

Re: what is the main difference between c and c++?

Answe The main difference between c and 1 K.r.sukumar


c++ is that " C is a
r
structured programming language
# 10 while C++ is an object
programming language and also we
have templates in C++ that
is not the case in C

385
Is This Answer Yes
Correct ? 62 No

Re: what is the main difference between c and c++?

Answe In C memory allocation is done with 2 Vivek Goyanr


malloc statement whereas
r
in C++ it is done through new
# 11 keyword.Also memory is
deallocated in C using free
statement while in C++
deallocation takes place through
delete.

294
Is This Answer Yes
Correct ? 74 No

Re: what is the main difference between c and c++?


Answe c++ support operator overloading 4 Uma
but
r
c doesn't support operator
# 12 overloading..

373
Is This Answer Yes
Correct ? 64 No

Re: what is the main difference between c and c++?

Answe C C++ 4 Mayuri


r
DATA IS NOT SECURED
# 13 SECURED

TOP DOWN
BOTTOM-UP

FOCUS ON PROCEDURES
FOCUS ON DATA

PROGRAMS ARE DECOMPOSED


INTO OBJECTS
INTO FUNCTIONS

allocation is done
NEW OPERATOR
with malloc statement

UNOINS AND ENUMS


AVALIABLE
ARE NOT AVALIABLE

DOES NOT PROVIDE


PROVIDES
DEFAULT ARGUMENTS

584
Is This Answer Yes
Correct ? 86 No

Re: what is the main difference between c and c++?

Answe C is a procedural Language, but C++ 2 Rajendra Kumar


is a object oriented
r Jena
language.
# 14
* C employs top down approach, but
c++ employes buttom up
approach.

* Here in C, when ever we are


writing a program, the data
are not secured from the outside
world. but in C++ data are
secured from the outside world.

* C give emphasis in algorithims


and functions, but C++
give emphasis on the data and
objects.

* In C we are using
#include<stdio.h> as header file,
but
in C++ we are using
#include<iostream.h> as header
file.

322
Is This Answer Yes
Correct ? 45 No

Re: what is the main difference between c and c++?

Answe C++ applications are generally 2 Shaliza Garg


slower at runtime, and are
r
much slower to compile than C
# 15 programs. The low-level
infrastructure for C++ binary
execution is also larger. For
these reasons C is always commonly
used even if C++ has
alot of popularity, and will
probably continue to be used
in projects where size and speed
are primary concerns, and
portable code still required
(assembly would be unsuitable
then).

166
Is This Answer Yes
Correct ? 58 No

Re: what is the main difference between c and c++?


Answe c is function or procedure oriented 2 Prakash Kumawat
whereas c++ is object
r
oriented.it focus primariy on tht
# 16 actions and events and
the programming model focuses on
the logical assertions
that trigger execution of programme
code whereas c++is
focusedon writingprogramas thet are
more readable and
maintainable and helps the reuse of
code by packing a group
of similar objects,inheritance and
polymorphism. C was THE
C++ predecessor. A lot of c
remains in c++.In c, the
result of applying the operator
size to a character
constant. for example:- size
of('c'),equalssize of (int).IN
c++,the expressionsize
of('c'),returns size of(char).

121
Is This Answer Yes
Correct ? 44 No

Re: what is the main difference between c and c++?

Answe c does not support the c++ 2 Dheeru Bhai


programme but c++ support the c
r
program.
# 17

242
Is This Answer Yes
Correct ? 46 No

Re: what is the main difference between c and c++?

Answe c is low level language while c++ 0 Ravi Pratap


is sn high level language.
r
c++ is an extension of c language
# 18 this means that you can
use not only the new features of c+
+ but can also use the c
programing on that. c++ is an
object oriented while c is an
program oriented in which you can
make new softwares.
152
Is This Answer Yes
Correct ? 82 No

Re: what is the main difference between c and c++?

Answe DIFFERENCE b/w C and C++ 3 Aashish Salotra


1.) C was the C++ predecessor.
r
As its name implies, alot of
# 19 C remains in C++. Although not
actually being more powerful
than C, C++ allows the programmer
to more easily manage and
operate with Objects, using an OOP
(Object Oriented
Programming) concept.

2.) C++ allows the programmer


to create classes, which are
somewhat similar to C structures.
However, to a class can be
assigned methods, functions
associated to it, of various
prototypes, which can access and
operate within the class,
somewhat like C functions often
operate on a supplied
handler pointer.

3.) Although it is possible to


implement anything which C++
could implement in C, C++ aids to
standardize a way in which
objects are created and managed,
whereas the C programmer
who implements the same system has
alot of liberty on how to
actually implement the internals,
and style among
programmers will vary alot on the
design choices made.

4.) In C, some will prefer the


handler-type, where a main
function initializes a handler, and
that handler can be
supplied to other functions of the
library as an object to
operate on/through. Others will
even want to have that
handler link all the related
function pointers within it
which then must be called using a
convention closer to C++.
5.) In C, there's only one
major memory allocation function:
malloc. You use it to allocate both
single elements and
arrays. In C++, however, memory
allocation for arrays is
somewhat different than for single
objects; you use the
new[] operator, and you must match
calls to new[] with calls
to delete[] (rather than to
delete).

6.) C++ applications are


generally slower at runtime, and
are much slower to compile than C
programs. The low-level
infrastructure for C++ binary
execution is also larger. For
these reasons C is always commonly
used even if C++ has alot
of popularity, and will probably
continue to be used in
projects where size and speed are
primary concerns, and
portable code still required
(assembly would be unsuitable
then).

7.) In C++, you are free to


leave off the statement 'return
0;' at the end of main; it will be
provided automatically
but in C, you must manually add it.

8.) A function can be declared


in C as int fun( );. This
means that fun( ) is a function
without any argument or any
number of arguments. But in C++,
this means that the
function with no argument at all.

9.) C++ support operator


overloading but c doesn't support
operator overloading.

165
Is This Answer Yes
Correct ? 30 No

Re: what is the main difference between c and c++?


Answe IN "C" WE CAN'T FOUND OPERATOR 3 Shaik Usman Ali
OVERLOADING CONCEPT WHERE AS
r
IN C++ IT IS POSSIBLE.THIS IS THE
# 20 FIRST AND FORE MOST
DIFFERENCE BETWEEN THESE TWO
LANGUAGES.
THAT TO BE "++ OPERATOR
OVERLOATING" IS DONE FIRST.
THIS IS THE MAJOR DIFFERENCE
BETWEEN C AND C++ PROGRAMMING
LANGUAGES.

139
Is This Answer Yes
Correct ? 39 No

Re: what is the main difference between c and c++?

Answe here are some difference between c 4 Daisy Golwala


and c++ ---
r
1. C is a PROCEDURE oriented
# 21 programming language.
-> C++ is a OBJECT oriented
programming language.
2. We can do programming through
STRUCTURE,but NOT with the
help of the CLASS.
-> We can do programming through
CLASS in c++.
3. C is a LOW level language.
->C++ is a HIGH level language.
4. C is a TOP->BOTTOM programming
approch.
->C++ is a BOTTOM->TOP programming
approch.
5. C is a collection of FUNCTIONS.
-> C++ is a collection of FUNCTIONS
and/or CLASS.
6. c language main focuses on
PROCEDURES.
-> c++ programming main focuses on
OBJECTS.
7. In C,DATA can be MOVE openly
around in the system from
function to function.
-> In C++,DATA is HIDDEn.It can not
be accessed by external
functions.
8.C can not support all the feature
of the C++.while c++
support all the features of C.
9. C NEEDS FORMAT CHARACTERS for
printing & scanning.
-> C++ DOES NOT REQUIRED FORMAT
SPECIFIER for printing and
scanning variable.
10. C variables are DECLARED in
declaration section.
-> C++ variables are DECLARED any
where in the program.
11. In C,we use PRINTF() ,SCANF()
as standard input/output
functions.
-> In C++,we can use COUT<< or
CIN>> as standard
input/output function.
12. In C,you can NOT OVERLOAD a
function.
-> In C++ ,you can OVERLOAD the
operator as well as
functions.
13. C does NOT have NAMESPACE for
avoid name collisions.
-> c++ has NAMESPACE feature.
14.C does NOT have REFERENCE
variables.
-> In C++ ,REFERENCE variables are
USED in functions.
15. In C,constants are defined as
'MACROS'.
-> We can make a use of 'CONST' TO
declare a constant.
16.In C program , the MAIN() should
NOT RETURN a value.
-> In C++,MAIN() should RETURN a
value.
17. C does NOT SUPPORT DEFAULT
arguments.
-> C++ PROVIDES DEFAULT argument
concept.

266
Is This Answer Yes
Correct ? 35 No

Re: what is the main difference between c and c++?

Answe C++ is object oriented language and 2 Luckyy


c is object based
r
language..
# 22

173
Is This Answer Yes
Correct ? 73 No
Re: what is the main difference between c and c++?

Answe DIFFERENCE b/w C and C++ 3 Rohit


1.) C was the C++ predecessor.
r
As its name implies,
# 23 alot of
C remains in C++. Although not
actually being more powerful
than C, C++ allows the programmer
to more easily manage and
operate with Objects, using an OOP
(Object Oriented
Programming) concept.

2.) C++ allows the programmer


to create classes, which
are
somewhat similar to C structures.
However, to a class can be
assigned methods, functions
associated to it, of various
prototypes, which can access and
operate within the class,
somewhat like C functions often
operate on a supplied
handler pointer.

3.) Although it is possible to


implement anything
which C++
could implement in C, C++ aids to
standardize a way in which
objects are created and managed,
whereas the C programmer
who implements the same system has
alot of liberty on how to
actually implement the internals,
and style among
programmers will vary alot on the
design choices made.

4.) In C, some will prefer the


handler-type, where a
main
function initializes a handler, and
that handler can be
supplied to other functions of the
library as an object to
operate on/through. Others will
even want to have that
handler link all the related
function pointers within it
which then must be called using a
convention closer to C++.

5.) In C, there's only one


major memory allocation
function:
malloc. You use it to allocate both
single elements and
arrays. In C++, however, memory
allocation for arrays is
somewhat different than for single
objects; you use the
new[] operator, and you must match
calls to new[] with calls
to delete[] (rather than to
delete).

6.) C++ applications are


generally slower at runtime,
and
are much slower to compile than C
programs. The low-level
infrastructure for C++ binary
execution is also larger. For
these reasons C is always commonly
used even if C++ has alot
of popularity, and will probably
continue to be used in
projects where size and speed are
primary concerns, and
portable code still required
(assembly would be unsuitable
then).

7.) In C++, you are free to


leave off the
statement 'return
0;' at the end of main; it will be
provided automatically
but in C, you must manually add it.

8.) A function can be declared


in C as int fun( );. This
means that fun( ) is a function
without any argument or any
number of arguments. But in C++,
this means that the
function with no argument at all.

9.) C++ support operator


overloading but c doesn't
support
operator overloading.

by:- ROHIT AGGARWAL


PUNJAB

140
Is This Answer Yes
Correct ? 24 No

Re: what is the main difference between c and c++?


Answe C gives importance to procedure. 2 S.kannigaarasu
That is functions rather
r
than data. The main function
# 24 couldnot return a value. It is
dont support c++ programme.
C++ gives importance to object that
is data. The main
function should return a value. It
is support c programme.

132
Is This Answer Yes
Correct ? 27 No

Re: what is the main difference between c and c++?

Answe C comes after A,B


r and c++ comes after adding ++ in C
# 25

S-ar putea să vă placă și