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);

}

相关推荐
CS创新实验室9 小时前
算法、齿轮与硅基大脑:数值计算发展简史
人工智能·算法·数值计算
似是燕归来9 小时前
嵌入式工程师进阶指南:适配器编程设计模式一
c语言·stm32·适配器模式·嵌入式开发
西门吹-禅10 小时前
java springboot N+1问题
java·开发语言·spring boot
skywalk816310 小时前
设计并实现段言的 C FFI 绑定机制 @Trae
c语言·开发语言·python·编程
海石10 小时前
1563分的简单题,可能就简单在能被暴力AC
算法·leetcode
海石11 小时前
1400分的dp汗流浃背之【交替子数组计数】
算法·leetcode
奋发向前wcx11 小时前
P2590 树的统计 题目解析
数据结构·算法·深度优先
imbackneverdie12 小时前
AI4S不止于分子药物:以MedPeer为代表的科研基建打开产业新增量
大数据·人工智能·算法·aigc·科研·学术·ai 4s
IT笔记12 小时前
【Rust】Rust Match 模式匹配详解
java·开发语言·rust
2zcode12 小时前
免费开源项目文档:基于MATLAB卷积神经网络的口罩佩戴检测系统
开发语言·matlab·cnn