标签:c语言 语言 main pre loading print ++ har src
1、
#include <stdio.h> int str_char(char x[], int key) { int len = 0; while(x[len]) len++; int i; for(i = 0; i < len; i++) { if(x[i] == key) return i; } if(i == len) return -1; } int main(void) { char str[128]; printf("str: "); scanf("%s", str); puts("\n================="); printf("position: %d\n", str_char(str, ‘c‘)); return 0; }
2、
#include <stdio.h> int str_char(char x[], int key) { int len = 0; while(x[len]) len++; int i = 0; while(1) { if(i == len) return -1; if(x[i] == key) return i; i++; } } int main(void) { char str[128]; printf("str: "); scanf("%s", str); printf("position: %d\n", str_char(str, ‘c‘)); return 0; }
标签:c语言 语言 main pre loading print ++ har src
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14817168.html