I have many times come across the statement char* ch = "hello";.
I understand that char* ch tells that ch is a pointer towards a char. But what does assigning hello to ch mean ?
I cannot undestand this ? please help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It means
chis a pointer to a character. When you dochar* ch = "hello"chwill be pointing to the first character i.e. characterh. To point to the second character, you can doch + 1orch[1]. Note that ideally the type ofchshould have beenconst char*as you can not write to the pointed memory location.