标题:输入一字符串 输出对应相对应的字符串 找不到愿意 啊 在linux上一直显示段 ...
取消只看楼主
summerxia
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-3-8
结帖率:0
 问题点数:0 回复次数:1 
输入一字符串 输出对应相对应的字符串 找不到愿意 啊 在linux上一直显示段错误
#include<stdio.h>
#include<string.h>
void main()
{
    char *p[10]={"em","cuz","gratz","i","nah","pos","sez","tanx","wuz"};
    char *q[10]={"them","because","grateful","I","no","supposed","said","thanks","was"};
    char s[]="nah i sez tanx cuz i wuz pos to not cuz i wuz gratz";
    char a[10];   
    int i,j,k=0;   
    while(1)
        {
       for(j=k,i=0;s[j]!=' ';j++,k++,i++)
          a[i]=s[j];
          a[i]='\0';
         
       for(i=0;i<10;i++)
       if(strcmp(a,p[i])==1)
         printf("%s ",q[i]);
        }
}  求帮忙啊
搜索更多相关主题的帖子: void linux because include 字符串 
2012-03-08 15:21
summerxia
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-3-8
得分:0 
大家帮帮忙啊
2012-03-08 15:44



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-362560-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.504083 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved