【发布时间】:2012-09-30 01:05:03
【问题描述】:
我的代码不起作用。在我接受字符串时出现运行时错误。这段代码有什么问题?
//this is what i have in main()
char *ele,*s[max];
int *count,temp=0;
count=&temp;
printf("Enter string to insert: ");
scanf("%s",ele);
addleft(s,ele,count);
//following is the function definition
void addleft(char *s[max],char *ele,int *count)
{
int i;
if((*count)==max)
{
printf("Queue full!\n");
return;
}
for(i=*count;i>0;i--)
strcpy(s[i],s[i-1]);
strcpy(s[0],ele);
(*count)++;
printf("String inserted at left!\n");
}
【问题讨论】:
-
我会将标题更改为“错误的代码实现导致错误的输入字符串处理”。标题听起来像是您将输入字符串归咎于代码错误。 ;-)
-
对不起,我没注意标题。此时对我来说更重要的是我必须提交这个 tom 的代码:)