Home > Back-end >  c
c

Time:09-27

To reverse an array output, not fixed array,

CodePudding user response:

 for (I=length - 1; i>=0; I -) 
Printf (" XXX ", arr [I]); [/color]

CodePudding user response:

[b] //the strlen function is used to calculate number of array elements within
if an array type is float, cannot use strlen function calculation of type double array [/b]
#include
# include

Int main ()
{
,2.1 char String [20]={1, 3,4,5,6,7,8,9};
Printf (" array reverse output \ n ");
//strlen () is used to calculate the length of the specified string s, not including end character \ "0",
For (int I=strlen (String) - 1; i>=0; I -)
Printf (" % d ", String [I]);
}
test results

CodePudding user response:

At the end when the value is 0
Char * available strlen determine length
Wchar *, long char *, wcslen (unsigned) short * available to determine length
Unsigned */int */float * write function on its own judgment
 
Unsigned pintlen (int * array) {
Unsigned len=0;
While (* array++) len++;
Return len.
}

(unsigned)/double long * * as above, when 32 in 64 when will the code above int instead of long