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...

char *ch = "abcde";
char c[4];
how to copy 'ch' to 'c'?

Answer Posted / parth ujenia

main()
{
char *ch="abcd";
char c[4];

for(int i=0;i<4;i++)
{
c[i]=*ch; //assign value to char c[i].
*ch++; //switch to next address of ch!
}

for(i=0; i<4 ;i++)
{
printf("%c - ",c[i]); //output will: a - b - c - d -
}

getch();

}

Is This Answer Correct ?    18 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is lazy initialization in c++?

1155


Does std endl flush?

1097


What is the best c++ book?

1327


Can we define function inside main in c++?

1073


How can you quickly find the number of elements stored in a dynamic array?

1098


Define copy constructor.

1180


Can we declare a base-class destructor as virtual?

1072


How can an improvement in the quality of software be done by try/catch/throw?

1140


What are files in c++?

1090


What is a string example?

1148


What are keywords in c++?

1161


Why isn't sizeof for a struct equal to the sum of sizeof of each member?

1059


How is computer programming useful in real life?

1122


Explain the auto storage classes in c++.

1156


Distinguish between new and malloc and delete and free().

1075