C

Asked • 05/26/19

What is the difference between char array vs char pointer in C?

I am trying to understand pointers in C but I am currently confused with the following:- char *p = "hello" This is a char pointer pointing at the character array, starting at _h_.- char p[] = "hello" This is an array that stores _hello_.What is the difference when I pass both these variables into this function? void printSomething(char *p) { printf("p: %s",p); }

1 Expert Answer

By:

Patrick B. answered • 05/26/19

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.