0
Follow
0
View

Does anybody have any idea what this code means and what the result is

dujingjing2013 注册会员
2023-02-27 15:07

the reference answer GPT ᴼ ᴾ ᴱ ᴺ ᴬ ᴵ < br / > this code implementation is the function of search string in the string CMDS ref, if found, it returns the content behind the ref, Otherwise returns a null pointer.
-
The implementation logic is as follows:
First searches cmds character by character and finds the first character that is the same as the first character of ref. Starting with this character, we then compare the following characters one by one to see if they are the same as the ref. If the comparison is the same all the way to the end of the ref string, it has been found and returns a pointer after this position in the cmds; Otherwise, continue looking for the next character until the entire cmds string is found. If none is found, return a null pointer.
-
The function returns a pointer to the cmds after the substring that matches the ref, which may be an empty string or a non-empty string. Calling this function needs to be judged and processed according to the specific situation.

c26533806 注册会员
2023-02-27 15:07

This code is supposed to check the match of the command line input parameters, ref string is the keyword, cmds is some command line parameter. When the command line argument starts with ref, it matches, and then returns the string after the keyword
The comment on standby already provides help, for example ref is "id:" and the command action entered is "id:asd", then the asd string is returned,
The code logic is to match the ref character by character in the cmds string from the beginning, true if all match, false otherwise

About the Author

Question Info

Publish Time
2023-02-27 15:07
Update Time
2023-02-27 15:07