| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 376 人关注过本帖
标题:运行程序时显示未响应~~求大神指教~~
只看楼主 加入收藏
pokerLee
Rank: 2
等 级:论坛游民
帖 子:41
专家分:29
注 册:2012-11-4
结帖率:93.33%
收藏
已结贴  问题点数:10 回复次数:2 
运行程序时显示未响应~~求大神指教~~
运行程序时显示未响应~~求大神指教~~编译器是codeblocks
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
char *str_in(void);
void str_sort(const char *[],int);
void swap(void **p1,void **p2);
void str_out(char *[],int);
#define BUFFER_LEN 256
#define NUM_P 50
int main(void)
{
    char *pS[NUM_P];
    int count=0;
    printf("\nEnter successive lines,pressing Enter at the end of each line.\nJust press Enter to end.\n");
    for(count=0;count<NUM_P;count++)
     if((pS[count]=str_in())==NULL)
      break;
    str_sort(pS,count);
    str_out(pS,count);
    return 0;
}
char *str_in(void)
{
    char buffer[BUFFER_LEN];
    char *pString=NULL;
    if(gets(buffer)==NULL)
     {
         printf("\nError reading string.\n");
         exit(1);
     }
     if(buffer[0]=='\0')
      return false;
     *pString=(char*)malloc(strlen(buffer)+1);
     if(*pString==NULL)
     {
         printf("\nOut of memory.");
         exit(1);
     }
     return strcpy(pString,buffer);
}
void str_sort(const char *p[],int n)
{
    char *pTemp=NULL;
    bool sorted=false;
    while(!sorted)
    {
        sorted=true;
         for(int i=0;i<n-1;i++)
         if(strcmp(p[i],p[i+1])>0)
         {
             sorted=false;
             swap(&p[i],&p[i+1]);
         }
    }
}
void swap(void **p1,void **p2)
{
    void *pt=*p1;
    *p1=*p2;
    *p2=pt;
}
void str_out(char *p[],int n)
{
    printf("\nYour input sorted in order is:\n\n");
    for(int i=0;i<n;i++)
    {
        printf("%s\n",*p);
        free(*p);
        *p++=NULL;
    }
    return;
}
搜索更多相关主题的帖子: 运行程序 void include 编译器 
2013-01-20 20:22
yaobao
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:4
帖 子:1854
专家分:4121
注 册:2012-10-25
收藏
得分:4 
不知道楼主的是什么编译器,但是stdbool.h这个头是要支持C99 的才有的,不知道这是不是原因

认认真真的学习,踏踏实实的走路:戒骄戒躁!!!
2013-01-20 20:41
xiaoshalong
Rank: 2
等 级:论坛游民
帖 子:20
专家分:16
注 册:2013-1-10
收藏
得分:4 
CB的编译器一般下载都自带的是GCC,除非楼主自己更换过..
GCC默认支持的自己查一下

[ 本帖最后由 xiaoshalong 于 2013-1-20 21:52 编辑 ]
2013-01-20 21:51
快速回复:运行程序时显示未响应~~求大神指教~~
数据加载中...
 
   



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

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