2009年7月21日 星期二

自訂一個strlen(c++)



#include <iostream>
using namespace std;
int strlen2(const char *ori);
int main(void){
cout<<strlen2("hello world")<<endl;
return 0;
}
int strlen2(const char *ori){
assert(ori !=NULL);
int len =0;
while(*ori++ !='\0'){
len++;
}
return len;
}

沒有留言:

張貼留言