This is a snippet from my code editor。我試圖運行這段代碼,並且無法理解while循環如何通過字符串。請解釋一下。什麼是string ++在for循環中在C++中實現strlen時在此處
#include <iostream>
using namespace std;
int my_strlen(char *string){
int length = 0;
while(*string !='\0'){
length++;
cout << string <<endl;
string++;
}
return(length);
}
int main() {
my_strlen("this is a test");
return 0;
}
請將郵政編碼作爲文字,而不是作爲圖片在這裏。 –
我很抱歉給您帶來不便。您能否請求幫助 –
您可以複製代碼粘貼到問題中,選擇它並按下CTRL-K。 –