Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のエラー メッセージを表示したい......エラー: 'const char*' から 'size_t' への変換が無効です</p>
return 0; } size_t strlen(const char *s1) { return s1 - 0; }
ポインターからゼロを引いてもポインターは変わりません。数値からゼロを引いても数値が変わらないのと同じです。
長さを取得するには、ゼロではなく元のポインターを減算する必要があります。
size_t strlen(const char *s1) { const char *orig = s1; while (*s1) { s1++; } return s1 - orig; }