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

}

相关推荐
gugucoding7 小时前
21. 【C语言】打包不同类型:结构体
c语言·开发语言
Brookty7 小时前
【JavaEE】线程安全(一).4:写块串行保安全、CAS
java·开发语言·java-ee·多线程·线程安全
Jerry8 小时前
LeetCode 151. 反转字符串中的单词
算法
F20226974868 小时前
西门子 PLC 与 C# 通信
开发语言·c#
gugucoding8 小时前
31. 【C语言】堆栈与队列的实现
c语言·开发语言·数据结构·链表
万联WANFLOW9 小时前
多分支企业组网,IP 网段到底该怎么规划
开发语言·php
阿里嘎多学长9 小时前
2026-07-07 GitHub 热点项目精选
开发语言·程序员·github·代码托管
a11177610 小时前
LM 算法迭代过程动画演示(SLAM)
算法
头茬韭菜10 小时前
Context 的生死抉择:四层压缩、截断算法与 Session Memory
算法·ai