现在的位置: 首页 > 综合 > 正文

c语言指针运行出现问题

2013年10月22日 ⁄ 综合 ⁄ 共 427字 ⁄ 字号 评论关闭
#include <stdio.h>
#include<string.h>
#define N 10
int main()
{
	int i;
	char s[10][20],*p[10];
	int sort(char *q,int n);
	printf("INput %d string :\n",N);
	for(i=0;i<N;i++)
	{
		p[i]=s[i];
		gets(p[i]);
	}
	printf("\n");
	for(i=0;i<N;i++)
		printf("%s\n",p[i]);
	sort(p,N);
	printf("\nAfter sorted :\n");
	for(i=0;i<N;i++)
	{printf("%s\n",p[i]);
	}

}
int  sort(char *q[],int n)
{
	int i,j;
	char *t;
	for(i=0;i<n-1;i++)
		  for(j=0;j<n-1-i;j++)
			  if(strcmpy(q[j],q[j+1])>0)
			  {
				  t=q[j];
				  q[j]=q[j+1];
				  q[j+1]=t;
			  }
}

抱歉!评论已关闭.