ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
what is mallloc()?how it works?
 Question Submitted By :: Manojkumar
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what is mallloc()?how it works?
Answer
# 1
malloc is briefly termed as Memory ALLOCation ......
whenever we write a program in C we will declare some
variables or arrays for a size more than whatever we need ,
etc etc..... so some variables are getting used correctly
and in arrays only some of the memory spaces are getting
used because the user dont know how much spaces he is gonna
use.......so here some memory is getting wasted without
using it.... so there comes a concept called DYNAMIC MEMORY
ALLOCATION in C...

we will give the values for how much memory we need at the
run time of the program... but this concept also only 85%
efficient... this has three types :
                  1)malloc();
                  2)calloc();
                  3)realloc();
malloc() is a function present in ALLOC.H standard library
which is used to allocate memory at run time (ie) in single
or in blocks.....

the syntax is :
pointer_variable=(typecasting
datatype*)malloc(sizeof(datatype));

this pointer variable should be of same datatype as the
typecasting datatype........

thank u
 
Is This Answer Correct ?    3 Yes 1 No
Vignesh1988i
 
  Re: what is mallloc()?how it works?
Answer
# 2
ya. this is an memory allocation porpose.
some other allocations are there calloc(), alloc()
 
Is This Answer Correct ?    0 Yes 0 No
Srinath, Hyd
 
 
 
  Re: what is mallloc()?how it works?
Answer
# 3
malloc function is used to allocate some space in memory for
the current program that we are running.
malloc() function actually return s the value of the address
of the memory in the memory segment
c=malloc();
it gives the address to the variable c.


h=malloc(sizeof(struct node));
it returns the address of structure for the variable h;
some h=1000; (address value)
 
Is This Answer Correct ?    0 Yes 0 No
Ravi Chandra
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Write a function that accepts two numbers,say a and b and makes bth bit of a to 0.No other bits of a should get changed. Scientific-Atlanta2
what is a static function Satyam10
How many ways are there to swap two numbers without using temporary variable? Give the each logic.  6
what is the hexidecimal number of 4100? Google14
What's the difference between a linked list and an array?  11
what does data structure mean?  7
which operator having lowest precedence?? a.)+ b.)++ c.)= d.)%  4
I have a function which accepts, and is supposed to initialize,a pointer, but the pointer in the caller remains unchanged.  1
what is the difference between getch() and getchar()?  5
what are the languages used in c#? Infosys1
sir, i cannot find the way how to write aprogram by using array on queue IISIT1
what information does the header files contain? BSNL5
what is the difference between #include<stdio.h> and #include "stdio.h" ?  2
What are Storage Classes in C ? HP15
related to rdbms query .  1
What character terminates all strings composed of character arrays? 1) 0 2) . 3) END  3
1)which of following operator can't be overloaded. a)== b)++ c)?! d)<= Siemens10
main() { int x=10,y=15; x=x++; y=++y; printf("%d %d\n",x,y); } output?? Ramco13
main() { printf("hello%d",print("QUARK test?")); }  4
What is the output for the following program #include<stdio.h> main() { char a[5][5],flag; a[0][0]='A'; flag=((a==*a)&&(*a==a[0])); printf("%d\n",flag); } ADITI5
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com