The following two loops represent the behavior of two functions in the standard
ID: 3548582 • Letter: T
Question
The following two loops represent the behavior of two functions in the standard C library.Can you identify what these loops do, and which function they stand for? int __________( char *s )
{
char *s1 = s;
while (*s1 != 0)
s1++;
return s1 - s;
}
char *__________( char *s1, char *s2 )
{
char *s = s1;
while ( (*s1 = *s2) != 0 )
{ s1++; s2++; }
return s;
} The following two loops represent the behavior of two functions in the standard C library.Can you identify what these loops do, and which function they stand for? int __________( char *s )
{
char *s1 = s;
while (*s1 != 0)
s1++;
return s1 - s;
}
char *__________( char *s1, char *s2 )
{
char *s = s1;
while ( (*s1 = *s2) != 0 )
{ s1++; s2++; }
return s;
}
Explanation / Answer
The first function denotes , the strlen function of the Standard C Library , the next one represents a strcpy function
1)Strlen - This function outputs the length of the given input string in integer format.
2)Strcpy - This function outputs the String which results from copying the string s1 to s2.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.