Although it appears as though these strings are being placed in the suit array

Although it appears as though these strings are being

This preview shows page 13 - 17 out of 17 pages.

respectively. Although it appears as though these strings are being placed in the suit array, only pointers are actually stored in the array Each pointer points to the first character of its corresponding string. Thus, even though the suit array is fixed in size, it provides access to character strings of any length. Arrays of Pointers
Image of page 13
©LPU CSE101 C Programming Program to show array of pointers. #include <stdio.h> void main() { int i; char * suit[4]={"spades","hearts","clubs“, “diamonds”} ; printf (“The suit of cards have:” ); for(i=0; i<4; i++){ printf("%s\n", suit[i]); } } The suit of cards have: spades hearts clubs diamonds
Image of page 14
©LPU CSE101 C Programming However pointers and arrays are different: A pointer is a variable. We can do pa = a and pa++. An Array is not a variable. a = pa and a++ ARE ILLEGAL
Image of page 15
©LPU CSE101 C Programming Practice session Practice various programs in detail in class on array of pointers. Example program To store address of different elements of an array. To display address of elements and address of pointers.
Image of page 16
©LPU CSE101 C Programming [email protected] Next Class: Dynamic Memory Management
Image of page 17

You've reached the end of your free preview.

Want to read all 17 pages?

  • Spring '18
  • Aman
  • Array, Pointer, Function pointer

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors