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

}

相关推荐
cjz389933 分钟前
双指针技巧:覆盖式双指针(原地覆盖)
算法
honker_X3 小时前
Python字符串全攻略:从入门到精通
开发语言·python
半杯咖啡半行码3 小时前
Qt 隐式共享(Implicit Sharing)深度解析:机制、陷阱与 Qt6迁移
开发语言·数据库·qt
吃我一窝jio3 小时前
Docker+Jenkins+K8s全流程部署
java·开发语言·笔记·python
eggwyw3 小时前
C++设计模式之解释器模式
开发语言·c++
橘子134 小时前
【高级数据库】关系代数基本概念
算法
mengge.cloud6 小时前
Python基础保姆级!从入门到入土
开发语言·python·云原生·pygame
在爪洼山玩泥巴6 小时前
fastjson2 JSONPath 取不存在路径,为什么会抛 “not support”?
java·开发语言·jsonpath·fastjson
电科_银尘15 小时前
【大模型算法与工程 15】手写Self-Attention:Q、K、V与缩放点积
算法
星落梦生16 小时前
SpringAOP基础笔记(7)
java·开发语言