# include "stdio.h"
# include "string. H"
Int main ()
{
Char s [5] [100].
Char * p;
* p=s;
Int I, k, len, minlen;
for(i=0; i<5; I++)
Gets (p + I);
Minlen=strlen (p + 0);
Printf (" % d ", minlen);
for(i=1; i<5; I++)
{
Len=strlen (p + I);
If (len
{
Minlen=len;
k=i;
}
}
Puts (p + k);
}
CodePudding user response:
What is a pointer variable
How is for pointer assignment
How is the goal of to the pointer assignment
This writing error is a pointer to pointer without a goal before target assignment
CodePudding user response:
Modified as follows, for your reference:
# include "stdio.h" # include "string. H" Int main (int arg c, char * argv []) { Char s [5] [100]. Char (* p) [100];//char * p P=s;//* p=s; Int I, k=0, len, minlen;//int I, k, len, minlen; for(i=0; i<5; I++) Gets (* (p + I));//gets (p + I); Minlen=strlen (* (p + 0));//minlen=strlen (p + 0); Printf (" % d \ n ", minlen);//printf (" % d ", minlen); for(i=1; i<5; I++) { Len=strlen (* (p + I));//len=strlen (p + I); If (len { Minlen=len; k=i; } } Puts (* (p + k));//puts (p + k); return 0; } CodePudding user response:
reference 1st floor forever74 response: what is a pointer variableHow is for pointer assignment How is the goal of to the pointer assignment This writing error is a pointer to pointer without a goal before target assignment Should be p=a, but the output of the answer, the printf (" % d ", minlen) do you have any questions just to test the calculation length of the string, the input string aa, his output is 11 CodePudding user response:
refer to the second floor QZJHJXJ response: modify as follows, for reference: # include "stdio.h" # include "string. H" Int main (int arg c, char * argv []) { Char s [5] [100]. Char (* p) [100];//char * p P=s;//* p=s; Int I, k=0, len, minlen;//int I, k, len, minlen; for(i=0; i<5; I++) Gets (* (p + I));//gets (p + I); Minlen=strlen (* (p + 0));//minlen=strlen (p + 0); Printf (" % d \ n ", minlen);//printf (" % d ", minlen); for(i=1; i<5; I++) { Len=strlen (* (p + I));//len=strlen (p + I); If (len { Minlen=len; k=i; } } Puts (* (p + k));//puts (p + k); return 0; } Ask: I don't understand the meaning of (* p) [100], haven't learned, and he gave the front code, can use char * p can't into a char (* p) [100] CodePudding user response:
line array pointer definition method is as follows: Data types (* pointer variable name) the number of columns] [two-dimensional array; For example, line array pointer are defined as follows: int (* p) [100]. It says there are about 100 a char type p points to the element of a one-dimensional array, namely the p for the row pointer, at this point, can be used as follows to the pointer p assignment: p=s; reference 4 floor m0_52291497 response: Quote: refer to the second floor QZJHJXJ response: modify as follows, for reference: # include "stdio.h" # include "string. H" Int main (int arg c, char * argv []) { Char s [5] [100]. Char (* p) [100];//char * p P=s;//* p=s; Int I, k=0, len, minlen;//int I, k, len, minlen; for(i=0; i<5; I++) Gets (* (p + I));//gets (p + I); Minlen=strlen (* (p + 0));//minlen=strlen (p + 0); Printf (" % d \ n ", minlen);//printf (" % d ", minlen); for(i=1; i<5; I++) { Len=strlen (* (p + I));//len=strlen (p + I); If (len { Minlen=len; k=i; } } Puts (* (p + k));//puts (p + k); return 0; } Ask: I don't understand the meaning of (* p) [100], haven't learned, and he gave the front code, can use char * p can't into a char (* p) [100] modify as follows: # include "stdio.h" # include "string. H" Int main (int arg c, char * argv []) { Char s [5] [100]. Char * p;//(* p) [100]; P=s [0];//* p=s; Int I, k=0, len, minlen;//int I, k, len, minlen; for(i=0; i<5; I++) Gets (p + I * 100);//gets (p + I); Minlen=strlen (p + 0); Printf (" % d \ n ", minlen);//printf (" % d ", minlen); for(i=1; i<5; I++) { Len=strlen (p + I * 100);//len=strlen (p + I); If (len { Minlen=len; k=i; } } Puts (p + k * 100);//puts (p + k); return 0; } CodePudding user response:
reference 5 floor QZJHJXJ reply: line array pointer definition method is as follows: Data types (* pointer variable name) the number of columns] [two-dimensional array; For example, line array pointer are defined as follows: int (* p) [100]. It says there are about 100 a char type p points to the element of a one-dimensional array, namely the p for the row pointer, at this point, can be used as follows to the pointer p assignment: p=s; Quote: refer to 4th floor m0_52291497 response: Quote: refer to the second floor QZJHJXJ response: modify as follows, for reference: # include "stdio.h" # include "string. H" Int main (int arg c, char * argv []) { Char s [5] [100]. Char (* p) [100];//char * p P=s;//* p=s; Int I, k=0, len, minlen;//int I, k, len, minlen; for(i=0; i<5; I++) Gets (* (p + I));//gets (p + I); Minlen=strlen (* (p + 0));//minlen=strlen (p + 0); Printf (" % d \ n ", minlen); nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull