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 output of printf("Hello World"-'A'+'B'); ?

1494


When can a far pointer be used?

1021


Do you know the difference between exit() and _exit() function in c?

1062


What does %d do?

1274


How are structure passing and returning implemented?

1035


pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)

2645


What are run-time errors?

1118


What are header files and what are its uses in C programming?

1233


What is the sizeof () a pointer?

988


What is enumerated data type in c?

1077


What is pointer and structure in c?

1173


What is a sequential access file?

1173


Explain what are run-time errors?

1086


What is the description for syntax errors?

1169


What is a function in c?

1574