c 从字符串数组中选择特定的字符串
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/*
* 输入2个字符串S1和S2,要求删除字符串S1中出现的所有子串S2,
* 即结果字符串中不能包含S2。
* 提示:输入数据的设计使得不可能出现输出为空的情况。
*/
char* slectStr(char** r,char** s,int a,int b);
int main(void)
{
char R[5][50] =
{
"Unreadable",
"Barely readable, occasional words distinguishable",
"Readable with considerable difficulty",
"Readable with practically no difficulty",
"Perfectly readable",
};
char S[9][50] =
{
"Faint signals, barely perceptible",
"Very weak signals",
"Weak signals",
"Fair signals",
"Fairly good signals",
"Good signals",
"Moderately strong signals",
"Strong signals",
"Extremely strong signals",
};
int rIndex = 1;
int sIndex = 3;
char* left = R[rIndex -1];
char* right = S[sIndex-1];
strlwr(right);
strcat(left,", ");
strcat(left,right);
printf("%s",left);
return 0;
}
/*
console log:
Unreadable, weak signals
Process returned 0 (0x0) execution time : 0.675 s
Press any key to continue.
*/
问题:如何通过函数实现,从字符串数组中,返回特定字符串?
阅读更多声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。