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

}

相关推荐
持敬chijing28 分钟前
Python-数据类型-列表
开发语言·python·青少年编程
SupL!34 分钟前
LoftQ原理
算法
xx~t1 小时前
嵌入式——51单片机1
linux·c语言·单片机·嵌入式硬件·51单片机
写后端的胖头鱼2 小时前
【高频面试题】Java 基础类型 + 包装类 + String 互相转换
java·开发语言
matlab代码2 小时前
基于matlab自助水果超市水果识别收费系统(GUI界面)【源码67期】
开发语言·matlab
Navigator_Z2 小时前
LeetCode //C - 1240. Tiling a Rectangle with the Fewest Squares
c语言·算法·leetcode
稻米哟2 小时前
力扣100——双指针
算法·leetcode
hui-梦苑2 小时前
[PHP]轻量主题函数WordPress 集成 KaTeX 数学公式渲染
开发语言·php·wordpress·katex
大圣编蚕2 小时前
Java StringWriter 详解:从入门到实战
java·开发语言·python
码行山野赴时序归途3 小时前
C语言预处理指令:编译前的“幕后导演“
c语言·开发语言