Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What's wrong with "char *p = malloc(10);" ?

Answer Posted / poornima

Nothing wrong.Its fine..
if u hve further doubt run the below code.

#include<stdio.h>
int main()
{
char *p=malloc(10);
if(p==NULL)
{
printf("malloc failed");
exit(0);
}
else
{
printf("malloc success\n");
p="hai";
printf("%s",p);
}
return 0;
}

o/p:
malloc success
hai

Is This Answer Correct ?    6 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference between exit() and _exit() function?

1113


Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

990


can any one provide me the notes of data structure for ignou cs-62 paper

2120


What is the sizeof () a pointer?

927


What is the use of define in c?

1004


Was 2000 a leap year?

1004


How many types of arrays are there in c?

998


Why malloc is faster than calloc?

1017


program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

2048


What are header files in c?

1024


What is far pointer in c?

1233


If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

1201


What are the types of macro formats?

1064


How can I prevent another program from modifying part of a file that I am modifying?

1012


Explain about block scope in c?

1034