白银的工业需求2018:帮我调试一下这段c语言代码。

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 06:53:42
以下这个我检查了几遍,在dev-cpp下运行的时
候运行到一半就蹦出 “xxx.exe遇到问题需要关闭,我们对次引发的不便表示抱歉。” 一类的。而且在tc2下通不过,但我现在想知道运行结果,谁能帮我看一下,谢谢。

#include <stdio.h>

#define lino 40

int main()
{
struct oz {
char actor[18];
int age;
char role[16];
};

struct oz cast[6]={
"judy",17,"doro",
"ray",35,"scar",
"bert",44,"cowar",
"jack",40,"tin",
"mar",37,"wick",
"frank",49,"the"
};
struct oz temp;
int line,x;

temp=cast[4];
cast[4]=cast[5];
cast[5]=temp;

puts("wizard of oz database!");

printf("%-18s\t%3s\t%-15s\n","actor","age","role");
for(line=0;line<lino;line++)
{
putchar('-');
}
putchar('\n');

for(x=0;x<6;x++)
printf("%-18s\t%3s\t%-15s\n",
cast[x].actor,\
cast[x].age,\
cast[x].role);
return (0);
}

就是把运行结果告诉我就行了,谢谢。




你是说虫子吗???(开玩笑而已)
什么 bug啊,c代码中也有bug,如何修正啊?

你的printf("%-18s\t%3s\t%-15s\n",
cast[x].actor,\
cast[x].age,\
cast[x].role); 错了,应该是
printf("%-18s\t%3d\t%-15s\n",
cast[x].actor,\
cast[x].age,\
cast[x].role);

Bug