Home > other >  I am a novice, there is a pointer to the topic, please everyone a great god teach me, thank you very
I am a novice, there is a pointer to the topic, please everyone a great god teach me, thank you very

Time:11-01


Copies the specified characters in a line of English to a character array and output, cannot use strncpy function,

Requirements: write a function f (char * s1, int start, int len, char * s2), * s1 character pointer to start from the first start continuous len characters copied to the character pointer * s1,

CodePudding user response:

Method has a lot of, can't use strncpy () function, use cycle
Void f (char * s1, int start, int len, char * s2)
{
int i=0;
While (len - & gt; 0)
{
[i++] s2=s1 [start++];//will correct s1, pointing to the value assigned to the correct s2 to memory
}
S2 [I]='\ 0';
}

CodePudding user response:

 
Void f (char * s1, int start, int len, char * s2)
{
int i=0;
While (len - & gt; 0)
{
[i++] s2=s1 [start++];//will correct s1, pointing to the value assigned to the correct s2 to memory
}
S2 [I]='\ 0';
}
  • Related