re-solve a few classic Huawei C language Face Test 1 , find the wrong void Test1 () { char string[10] char* str1= "0123456789"; strcpy (string, str1); here the string array is out of bounds because the string length is 10 and there is a Terminator '/0 '. So there are a total of 11 characters in length. The string array has a size of 10, and here it crosses. PS: When using the strcpy function, be sure to be aware that the previous destination array must be larger than the size of the string behind it, otherwise the access is out of bounds. void Test2 () { char string[10], str1[10] for (i=0; i<10;i++) { Str1[i] = ' a '; } strcpy (string, str1); Here's a glimpse of the problem, which is that the variable i is not defined, which in the code compile phase the compiler can help you find it easy to handle. However, many problems are caused by their own vulnerabilities, the compiler is not helpful. The biggest problem here is that STR1 has no terminator, because the second argument of strcpy should be a string constant. The function is to use the end of the second argument to determine whether the copy completed. So after the For loop should add str1p[9] = '/0 '; PS: The most obvious difference between a character array and a string is that the string is prefixed by the default with the Terminator '/0 '. void Test3 (char* str1) { char string[10]; if (strlen (str1) <=10) & nbsp { strcpy (string, str1); the problem here is still a cross-border problem. The strlen function gets the length of the string except the Terminator. If this is a <=10, it's obviously out of bounds. Summary: The above three error-finding functions are primarily to examine the mastery of the concepts of strings and character arrays, as well as the understanding of strcpy functions and strlen functions.2 , find the wrongDSN get_srm_no () {static int srm_no; int I; for (i=0;i<max_srm;i++) {srm_no%= max_srm; if (My_srm.state==idle) {break; } if (I>=MAX_SRM) return (NULL_SRM); else return srm_no; Here for The Loop's judgment statement is later I added, the estimate is circulated on the Internet when people lost, according to the analysis of the program, to make up. The wrong estimate should not be here. By simply reading this function, you can probably guess that the function of this function is to allocate an idle SRAM block. Methods: the RAM block from the last allocated RAM block was detected to detect the idle state and, if it was idle, the current RAM block number srm_no. If all of the RAM blocks are not idle states, it means that you cannot allocate a RAM to the function caller, and return a flag indicating that there is no RAM to allocate (NULL_SRM). After the analysis above, we can see here that the error of this function is not to add 1 to srm_no this variable in the For loop.3. Write out the results of program Operationint sum (int a) {auto int c=0; static int b=3; C+=1; b+=2; return (A+B+C); } void Main () {int I; int a=2; for (i=0;i<5;i++) {printf ("%d,", sum (a)); The result of the run is: 8,10,12,14,16, in sum function sum c is auto variable, according to the auto variable characteristics of each call the SUM function, the variable C will automatically assign a value of 0. b is a static variable, and according to the static variable, variable B uses the value saved by B at the time the SUM function was last called. A simple analysis of the function, you can know that if the parameters passed in, then each call to return the SUM function 2 more than the last. So the answer is: 8,10,12,14,16,4, func (1) =. int func (int a) {int b; Switch (a) {case 1:30; Case 2:20; Case 3:16; default:0; return b; You may have forgotten to assign a value to variable B in a case statement. If you change to the following code: int func (int a) {int b; Switch (a) {case 1:b = 30; Case 2:b = 20; Case 3:b = 16; default:b = 0; return b; Because the break statement is missing from the case statement, the result is 0, regardless of the parameters passed to the function.5, a[q-p] =. int a[3]; a[0]=0; A[1]=1; a[2]=2; int *p, *q; P=a; q=&a[2]; Very obvious: a[q-p] = a[2] = 2;6, Memory space occupancy problemdefine int **a[3][4], the memory space that the variable occupies is: 16-bit system -, the 32-bit compilation system is -。 PS: Formula: 3 * 4 * sizeof (INT * *).7. Program Writing Write a function that requires you to enter the date and time of the month and the next second of the day. If you enter December 31, 2004 23:59 59 seconds, then output January 1, 2005 0:0 0 seconds. void resetthetime (int *year,int *month,int *date,int *hour,int *minute,int*second) { int dayofmonth[ 12]={31,28,31,30,31,30,31,31,30,31,30,31}; if (*year < 0 | | *month < 1 | | *month > | |   ; *date < 1 | | *date > 31 | | *hour < 0 | | *hour > 23 | | *minute < 0 | | *minute > 59| | *second <0 | | *second >60) return; if (*year%400 = 0 | | *year%100!= 0 && *year%4 = 0) Day OFMONTH[1] = 29; if (*second >=) { *second = 0; & nbsp; *minute + + 1; if (*minute >= 60) { *minute = 0; *hour + 1; if (*hour >=) { * hour = 0; *date + 1; if (*date > Dayofmonth[*month-1] ) { *date = 1; *month + = 1; if (*month >) { *month=1; *year + 1; } } } } } return; }