(1) Use the function to find the largest value of a, B and in the order of large to small output
int MAX (int a,int b,int *p,int *q)
{
p=&a;//to write in the main function, the reason is not clear ... Anyway, to write the answer here is wrong, change to the main function is right, and can only define a main function or call function
q=&b;
if (a<b)
{
int c=a;//Anyway, *p is a, it's not standard, but it's right.
*p=b;
*q=c;
}
return A;
}
#include <stdio.h>
int main ()
{
int MAX (int a,int b,int *p,int *q)
int A, B;
int *p,*q;//should be int *p=a,*q=b;
Max (A,B,P,Q);
scanf ("%d%d", &a,&d);
printf ("%d\n", a);
printf ("%d%d", A, b);
return 0;
}
Error code, correcting://
Note: The definition is always *p, when called with P;
int *p=&a==int *p; p=&q;
Modified version:
If you change to a global variable:
Looks like me. The calling function is not on the front, and the global variable is best capitalized;
Suddenly think of a # define IP 3.14
(2) pointers and one-dimensional arrays
1.A[5] Output
#include <stdio.h>
int main ()
{
int a[5]={0,1,2,3,4};
int *p=a;//Note and the preceding difference int *p=&a; is the definition pointer p,p as address, the address is &a; but really should be int *p;int p=&a; But here, a represents the first address of a[5]
for (;p <a+5;p++)
printf ("%d", *p);
}
Want to input plus output
I don't know what's wrong, woo-hoo.
I came back and changed the wrong way.
Note that the current value of the pointer variable precedes the previous one that has been added to the a+5
Change the following, this is correct
Looks like I just saw this kind of.
Typical error
A is a constant cannot be ++;p a variable
Improved
P++;*p = = *p++ ==* (p++) ==a[i++]* and + + are the same priority, right-to-left, forget, later in the order of confusion, with parentheses
It's not too early to write tomorrow.
Want to comb the hands