You are here:

C++/Char Pointer

Advertisement


Question
Hello !!

i am initializing the char pointer with 5 names. How will I print it  :

char *p[]={"anand","abhi","John","Ana","Geshu"};

I just want to print all the names in different lines using *p.

Please help.

Thanks


Answer
Hi Priya

You can do it like this

char *p[]={"anand","abhi","John","Ana","Geshu"};
int i

for(i=0;i<5;i++)
printf("%s",*(p + i));

Do lemme know if you get any problem with the above code.

regards
Joydeep Bhattacharya
http://www.scodz.com

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Joydeep Bhattacharya

Expertise

TSR, Socket and Very Complex Mathematical Problem

Experience

Worked on many OOP projects with design patterns

Organizations
http://www.scodz.com

Publications
http://www.scodz.com

Education/Credentials
Master of Computer Applications

Awards and Honors
Being a proud owner of a website of programming called http://www.scodz.com

Past/Present Clients
http://www.funforu.com http://www.dhoondho.com http://analysingc.50webs.com

©2016 About.com. All rights reserved.