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

}

相关推荐
Wang's Blog29 分钟前
Java 项目实战: 外卖平台优化-Nginx配置文件结构与块层级
java·开发语言·nginx
2601_962071571 小时前
类变量和全局变量的查找路径有什么区别?
开发语言·python
hetao17338372 小时前
2026-10-03~04 hetao1733837 的刷题记录
c++·算法
\光辉岁月/2 小时前
5.java-数组
java·开发语言
Java后端的Ai之路2 小时前
Python进阶探索29_eval内置函数
开发语言·python·探索·eval·内置函数
谢亮_vipxieliang2 小时前
Spring 事务失效的常见场景
java·开发语言·数据库·spring boot
Zootopia6262 小时前
飞行力学知识梳理1|飞行性能与稳定性
人工智能·python·算法·机器学习·无人机·学习方法·信息与通信
longlongzihan2 小时前
从LeetCode 70. 爬楼梯看动态规划:如何精准推导状态转移方程?
c++·算法·leetcode·动态规划
时间的拾荒人2 小时前
Qt 多线程详解:从 QThread 到实战
开发语言·qt·面试
郑州光合科技余经理3 小时前
海外版外卖加盟:总站与分站配送规则怎么分开管
java·开发语言·前端·后端·uni-app·php·ai编程