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

}

相关推荐
OPEN-F3 分钟前
C++进阶教程:继承与多态
开发语言·c++
鹿角片ljp2 小时前
LeetCode 236. 二叉树的最近公共祖先|递归后序
算法
luj_17682 小时前
大律师考核应重能力与科技素养
c语言·开发语言·c++·经验分享·算法
无定义_2 小时前
Floyd——Warshall
算法
刃神太酷啦2 小时前
Linux 系统 MySQL 完整安装配置教程:从卸载 MariaDB 到优化 my.cnf----《Hello MySQL!》(1)
android·linux·c语言·c++·mysql·leetcode·mariadb
带多刺的玫瑰3 小时前
Leecode#9刷题之回文数
数据结构·算法
leonkay3 小时前
C# 特性(Attribute)——【1】基础讲解
开发语言·青少年编程·面试·c#·.net·个人开发
harmful_sheep3 小时前
java group by常见用法
java·开发语言·python
泯泷3 小时前
手搓JSVM第 5 篇:写第一个编译器:从 AST 生成 IR
前端·javascript·算法
SKH.3 小时前
Linux软件编程(6)线程间通信
java·开发语言·数据库