65,211
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <iostream>
using namespace std;
int f(char *s)
{
char *p=s;
while(*p!='\0')p++;
return(p-s);
}
void main()
{
cout<<f("good")<<endl;
}
#include <iostream>
using namespace std;
int f(char *s)
{
char *p=s;
while(*p!='\0')p++; //p循环到字符串末
printf("%d\n",p); //输出p的地址
printf("%d\n",s); //输出s的地址
return(p-s); //返回地址之差
}
void main()
{
cout<<f("food")<<endl;
}