Answer to Question #301311 in C++ for adi

Question #301311

Write a program to demonstrate the use of pointer to pointer. Make a list of characters (a word) by char *word, another list of words (a sentence) using char **sentence. Print the sentence using a double pointer.


1
Expert's answer
2022-02-23T06:23:52-0500
using namespace std;




/*
	Write a program to demonstrate the use of pointer to pointer. 
	Make a list of characters (a word) by char *word, another list of words (a sentence) using char **sentence. 
	Print the sentence using a double pointer.
*/


int main()
{
	char w[] = "Hello World";
	char *word, **sentence;
	int r;
	
	word  = &w[0];
	sentence = &word;
	
	cout<<"\n\tWord = "<<w;
	
    cout<<"\n\tWord available at *ptr = ";
	for(r=0;r<11;r++) cout<<*(word+r);


    cout<<"\n\tSentence available at **sentence = ";
	for(r=0;r<11;r++) cout<<*(sentence+r);
	return(0);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog