C language: outputs the scores of each student in a two-dimensional array using pointer functions. The pointer is a two-dimensional array.
//
// Main. c
// Pointer_function
//
// Created by ma c on 15/8/2.
// Copyright (c) 2015 bjsxt. All rights reserved.
// Requirement: when a student ID is input through the pointer function, the corresponding Student Score is displayed on the console.
# Include <stdio. h>
Float * search (float (* p) [4], int n) // float (* p) [4] is an array pointer, the first line pointing to the two-digit array with four float Elements
{
Float * pt;
Pt = * (p + n );
Return pt;
}
Int main (int argc, const char * argv [])
{
Float score [] [4] = {99,98, 97,99}, {88,97, 96,96}, {96,95, 93,90 }};
Int sno;
Printf ("please input sno is (0, 1, 2 ):");
Scanf ("% d", & sno );
Float * p = search (score, sno); // call the pointer function and return a pointer.
For (int I = 0; I <4; I ++)
{
Printf ("%. 1f", * (p + I); // traverses the result of each row
}
Printf ("\ n ");
Return 0;
}