运行错误。。找不到了。。唉。。

小神流川 2010-09-19 06:40:11
#include<fcntl.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include<sys/ioctl.h>
#include<sys/types.h>
#include<linux/kd.h>
int main()

{ pid_t pid;
pid=fork( );
int j;
switch (pid)
{
case -1:
perror("fork failed");
exit(0);
case 0:
voice();
exit(1);
default:
choice();
exit(1);
}
}
int pic1()

{ printf ("     %%%%%%% \n");
printf ("        %%/\ /\%, \n");
printf ("        %%%\c -- J/%%, \n");
printf (" %.     %%%%/ d b \%%% \n");
printf (" `%%.     __   %%%  _ |%%% \n");
printf (" `%%   .-'  '"~--"`%%%%%(=_Y_=)%%%' ~~~ \n");
printf (" //  .'   `.   `%%%%`\7/%%%'____ \n");
printf ("  ((  /     ;   `%%%%%%%'____))) \n");
printf (" `.`--'     ,'  _,`-._____`-, \n");
return 0;
};
int pic2()
{

printf(" ,%%%%%%% \n");
 printf("        ,%%/\%%%%/\% \n");
 printf("          %%%\c "" J/%% \n");
 printf(" %.         %%%%/ d b \%%% \n");
 printf(" `%%.     __  %%%%  _ |%%% \n");
 printf(" `%%    .-' `"~--"`%%%%(=_Y_=)%%' ~~~ \n");
 printf("  //  . '   `.   `%%%%`\7/%%%' \n");
 printf(" ((  /     ;   `%%%%%%%' \n");
 printf(" | / | | | * * \n");

printf(" | / | | | |* * \n");

printf(" |_ * |__ * |__* |_* \n");

return 1;
};

int voice(int grac, char **argv)
{
int console_fd;
int i;
int s[ ]={523,587,659,523,523,587,659,523,659,698,784,659,698,784,
784,880,784,698,659,523,784,880,784,698,659,523,659,392,523,659,392,523};
int len[ ]={500,500,500,500,500,500,500,500,500,500,500,750,500,500,500,250,250,250,250,500,500,250,250,250,250,500,500,500,500,500,500,500,500};
if((console_fd=open("/dev/console",O_WRONLY))==-1)
{

fprintf(stderr,"failed to open.\n");
perror("open");
exit(1);
}
for(i=0;i<32;i++)
{
int magical_fairy_number =1190000/s[i];
ioctl(console_fd,KIOCSOUND,magical_fairy_number);
usleep(1000*len[i]);
ioctl(console_fd,KIOCSOUND,0);
usleep(1000*50);
}
char output[30];
read(0,output,30);
printf("%$ /n child,child. \n",output);
return(0);
};
void choice()
{
int j,k,l=0;
k=rand()%2;
for (j=16;j>=0;j--)
{
if (l==k)
{
l= pic1();
pic1();
}
else
{
l= pic2();
pic2();
}
//switch
sleep(1);
}
// k=k+1;
// k%2;
//for
};
我运行的时候有错误啊。。可是不知道哪里错了。。大家帮我看看呗~~~~~~~~
[root@localhost root]# cc -o child child.c
child.c:30:19: warning: unknown escape sequence: '\040'
child.c:31:19: warning: unknown escape sequence '\c'
child.c: In function `pic1':
child.c:34: parse error before '~' token
child.c: In function `pic2':
child.c:44: stray '\343' in program
child.c:44: stray '\200' in program
child.c:44: stray '\200' in program
child.c:45: stray '\343' in program
child.c:45: stray '\200' in program
child.c:45: stray '\200' in program
child.c:45:12: warning: unknown escape sequence '\c'
child.c:46: stray '\343' in program
child.c:46: stray '\200' in program
child.c:46: stray '\200' in program
child.c:47: stray '\343' in program
child.c:47: stray '\200' in program
child.c:47: stray '\200' in program
child.c:48: stray '\343' in program
child.c:48: stray '\200' in program
child.c:48: stray '\200' in program
child.c:48: parse error before '~' token
child.c:49: stray '\343' in program
child.c:49: stray '\200' in program
child.c:49: stray '\200' in program
child.c:50: stray '\343' in program
child.c:50: stray '\200' in program
child.c:50: stray '\200' in program
child.c:51: stray '\343' in program
child.c:51: stray '\200' in program
child.c:51: stray '\200' in program
child.c: At top level:
child.c:88: warning: type mismatch with previous implicit declaration
child.c:23: warning: previous implicit declaration of `choice'
child.c:88: warning: `choice' was previously implicitly declared to return `int'[root@localhost root]#
...全文
153 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
louyong0571 2010-09-20
  • 打赏
  • 举报
回复
字符问题,楼主问题解决该结贴了
小神流川 2010-09-20
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 eclipse_2 的回复:]
直接从网上粘贴下来的吧
很多字符都不识别
[/Quote]
谢谢了,昨天找到了。。
小魔菇 2010-09-19
  • 打赏
  • 举报
回复
直接从网上粘贴下来的吧
很多字符都不识别

23,114

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧