您好,登錄后才能下訂單哦!
#include<stdio.h> #include<stdlib.h> #include<assert.h> char *my_strchr(const char *dst, char c) { assert(dst); const char *pdst = dst; while (*pdst) { if (*pdst == c) return (char *)pdst; else pdst++; } return NULL; } int main() { char c=0; char arr[40]={0}; char * = NULL; scanf("%c", &c); scanf("%s", arr); str=my_strchr(arr, c); printf("%#p\n",*str); system("pause"); return 0; } #include<stdio.h> #include<stdlib.h> #include<assert.h> char *my_strrchr(const char *src, char c) { assert(src); const char *psrc = src; char *dst = NULL; while (*psrc) { if (*psrc == c) dst =(char *) psrc; psrc++; } return dst; } int main() { char c = 0; char arr[40]; char *place = NULL; scanf("%c%s", &c, arr); place = my_strrchr(arr, c); printf("%#p\n",place); system("pause"); return 0; } //strrstr庫里面沒有 #include<stdio.h> #include<stdlib.h> #include<assert.h> char *my_strrstr(const char *dst, const char *src) { assert(dst); assert(src); const char *pdst = dst; const char *psrc = src; char *right= NULL; while (*dst) { while (*pdst == *psrc) { if (*pdst== '\0') return right=(char *)dst; else { pdst++; psrc++; } } if (*psrc == '\0') right = (char *)dst; pdst = ++dst; psrc = src; } return right; } int main() { char arr1[50] = { 0 }; char arr2[40] = { 0 }; char *place = NULL; scanf("%s%s",arr1, arr2); place = my_strrstr(arr1, arr2); printf("%#p\n",place); system("pause"); return 0; }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。