However, after reviewing the submission details, the length of the string could not be negative, so he decided to change the return type of the My_strlen function.
Jerry uses the git log command to view the log information.
[[email protected] project]$ git log
The above command produces the following results.
Commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 Author:jerry Mouse <[email protected]> date:wed Sep 11 08:05:26 20 +0530 implemented My_strlen function
Jerry uses the git show command to see the details of the commit. The SHA-1 commit ID of the GIT show command as a parameter.
[[email protected] project]$ git show cbe1249b140dad24b2c35b15cc7e26a6f02d2277
The above command produces the following results.
Commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 Author:jerry Mouse <[email protected]> date:wed Sep 11 08:05:26 20 +0530 implemented My_strlen function diff–git a/string.c b/string.c new file Mode 100644 index 0000000..187afb9-/dev /null + + + b/string.c @@ -0,0 +1,24 @@ -0,0 #include <stdio.h> + +int My_strlen (char *s) +{+ char *p = s; + + while (*p) + ++p; + RETURN (p-s); +} +
He changed the return type of the function from int to size_t. after testing the code, he looks at its changes to run the git diff command.
[[email protected] project]$ git diff
The above command produces the following results.
Diff–git a/string.c b/string.c Index 187AFB9. 7da2992 100644-a/string.c + + + b/string.c @@ -1,6 +1,6 @@ -1,6 <stdio.h>-int my_strlen (char *s) +size_t my_str Len (char *s) {char *p = s; @@ -18,7 +18,7 @@ -18,7 main (void)}; for (i = 0; i < 2; ++i) –printf ("string lenght of%s =%d/n", S[i], My_strlen (S[i])); + printf ("string lenght of%s =%lu/n", S[i], My_strlen (S[i])); return 0; }
The Git diff shows the + sign forward, which is newly added, and the display symbol is deleted.
PS: If you want to communicate with the industry technology Daniel, please add QQ Group (521249302) or pay attention to the public number (askharries), thank you!
Git Review Changes