strchr 的初学者应用

来源:互联网 发布:淘宝面包鞋豆豆鞋 编辑:程序博客网 时间:2024/06/14 16:21

strchr ()返回的是 char*

#include<iostream>#include<cstring>#include<cstdio>using namespace std;int main() {char s[10] ;cin >> s;char* idx = strchr(s, 'd');printf("%d %p %p %p", idx-s, idx-s , s, idx);  return 0;}

 4 == (23fe34-23f330) / 1     "1"为char所占字节。

唉,说到底,还是指针加减法问题。。。。

0 0
原创粉丝点击