📄 l30.1a
字号:
#printWrite a subroutine named "locn(s,c)" which expects twoarguments: the first is a pointer to characters 's' whichpoints to a null-terminated string, and the secondis a character 'c' which is to be searched for in thestring 's'. If the character 'c' does notappear in the string return 0; otherwise return a pointerto the position of 'c' in the string. Name the program "locn.c";as usual, compile and test it and then type "ready".#once #create Ref0190250#once #create tzaqc.cchar *alpha "abcdefghijklmnopqrstuvwxyz";main(){ extern char *locn(); printf("%d\n", locn(alpha, '+')); printf("%d\n",locn(alpha, 't')-alpha); printf("%d\n",locn(alpha, 'a')-alpha); printf("%d\n",locn(alpha, 'z')-alpha); printf("%d\n",locn("", 'z'));}#usercc tzaqc.c locn.oa.out >value#cmp value Ref#succeed/* Try this: */char *locn (s, c)char *s;{ for( ; *s; s++) if (*s == c) return(s); return(0);}#log#next31.1a 10
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -