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

}

相关推荐
令狐掌门5 分钟前
2026华为OD面试题020:日志文件异常检测
算法·leetcode·华为od
炸薯条!7 分钟前
从零开始学C++(4) --类和对象
开发语言·c++·算法
渡我白衣7 分钟前
打印宏与socket模块设计
java·linux·开发语言·c++·ide·人工智能·eclipse
haluhalu.14 分钟前
prompts.chat:07-few-shot-prompting
人工智能·算法
Wang's Blog17 分钟前
Go-Zero框架上手前奏2: 微服务核心要素 —— 拆分、通信与无状态设计
开发语言·微服务·golang
Jerry24 分钟前
LeetCode 150. 逆波兰表达式求值
算法
浩瀚地学30 分钟前
【面试算法笔记】0106-数组-区间和
笔记·算法·面试
Jerry6 小时前
LeetCode 1047. 删除字符串中的所有相邻重复项
算法
可编程芯片开发8 小时前
基于霍尔传感器和PID控制器的有功功率检测控制系统simulink建模与仿真
算法