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

#include #include struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

6263


Why do we use header files in c?

1055


If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402

3897


Explain how do you generate random numbers in c?

1068


What is header file in c?

1053


What are comments and how do you insert it in a C program?

1231


In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

2101


What is #include stdio h and #include conio h?

1088


Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?

1113


What is structure data type in c?

1006


What do the functions atoi(), itoa() and gcvt() do?

1167


What oops means?

983


Can we assign string to char pointer?

1080


Differentiate between functions getch() and getche().

1026


Why is it that not all header files are declared in every C program?

1190