Home > Back-end >  O great spirit in C and C can be
O great spirit in C and C can be

Time:10-24

Please write a program that reads in 10 of the float type data is stored in the appropriate type of variable, and the output to the screen, respectively, with the following two ways:
(1) to use an array to obtain the static storage space in a row, use the pointer access to continuous variables in the storage space;
(2) using malloc or new dynamic application continuous space, use subscript access to continuous variables in the storage space,

CodePudding user response:

Basic problem, write yourself
The wrong post code to ask
The first question
Float fArray [10].
Float * p=fArray;
Loop into the array to
Cycle again with a subscript fArray [I] output, or a * (p + I) output

The second problem
Float * fP=(float *) malloc (10 * sizeof (float).//fp=new float [10] can also
The rest is pointer manipulation bai

Read a book!
  • Related