C Primer Plus(第六版)11.13 编程练习 第6题

#include<stdio.h>

#define SIZE 40

int is_within(char ch,char str\[\]);

int main(void)

{

int i = 0;

char *p;

char ch;

char storeSIZE = "abcd";

while(ch!='q')

{

printf("q to quit\n");

scanf("%c",&ch);

while (getchar() != '\n')

continue;

i = is_within(ch,store);

if(i!=0)

printf("%c在%s第%d位\n",ch,store,i);

else printf("没找到%c\n",ch);

}

return 0;

}

int is_within(char ch,char str\[\])

{

char *p=NULL;

int i=0;

while(i<sizeof(str))

{

if(stri == ch)

{

p=&stri;

}

i++;

}

if(p==NULL)

return 0;

else

return (p-str+1);

}

相关推荐
D e re k ZH2 分钟前
C++ 并发、未定义行为与工程化难点(No 3)
数据结构·c++·算法·面试
不积跬步无以至千里mmbb2625 分钟前
rust_analysis
开发语言·后端·rust
释厄6231 小时前
同性线套娃律——圆面积必然=1+2+...+n 的求和·圆心不与 π 相关
java·人工智能·算法·1024程序员节
暴力求解1 小时前
C++ ---继承(二)
开发语言·c++·算法
陈飞EXCEL1 小时前
北京杰飞 IT 旗下妙码生花少儿Python编程上线两大学习系统
开发语言·python·学习
码林拾遗WJ1 小时前
告警分级的自动化实测:模型判断 vs 人工拍板
人工智能·算法·自动化
Tisfy2 小时前
LeetCode 0453.最小操作次数使数组元素相等:两次遍历(反向思维)
算法·leetcode·题解·遍历·反向思维
代龙涛2 小时前
WordPress Query 查询机制详解(WP_Query)
开发语言·后端·php·wordpress
君万2 小时前
【LeetCode每日一题】回溯:46. 全排列 78. 子集 39. 组合总和
算法·leetcode·go
znsoft2 小时前
MaClaw(码卡龙)技术拆解:一个 Go + React 的可自进化智能体平台
开发语言·react.js·golang