Operate two-dimensional array C language with pointers

Source: Internet
Author: User


// Use a pointer to operate a two-dimensional array float (* pointer) [4], pointerIs a float * Type Variable, To see clearly! Points to a one-dimensional array with four elements.

Float * search (float (* pointer) [4], int N)

See this writing!

// Note !! * (Pointer + n) and (* pointer + n.
// Pointer Points to a two-dimensional array !! That is, pointer is of the int ** type. * pointer + N is equivalent to adding N to the subscript of one-dimensional array.

Int main () {float score [] [4] = {60, 70, 80, 90}, {56, 89, 67,88}, {34, 78, 90,66 }}; // score + I is the first address of the ground I line float * search (float (* pointer) [4], int N); // (* pointer) [4]? Represents an array float * P; int I, m; printf ("Number of Students input:"); scanf ("% d", & M ); P = search (score, m); for (I = 0; I <4; I ++) printf ("% 5.2f \ t", * (p + I )); printf ("\ n"); float * search (float (* pointer) [4], int N) {float * PT; Pt = * (pointer + n ); return (PT) ;}return 0 ;}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: