编程错误提示: missing terminating ' charater 是什么意思 ?
我用的是 c 语言 !刚开始调试 就提示 ! 好象就更本没有 调试 ! 在你的最后一个大括号后面敲一个回车,然后保存,再编译试试 谢谢 !`
我去试试 ! 呵呵~~应该不行~~~你说说你是怎么调试的吧 gcc prodesign.c
突然可以了!
但是 运行时 提示:
Segmention default 还有 提示:
assignment makes integer from pointer withouta cast 应该是你编的程序有问题吧。
程序要是不是太长的话贴出来看看吧。 hao ba! #include<sys/types.h>
#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
pid_t p1,p2,p3,p4;
intmain(void){
int Randomnum(void);
struct stares1{ int s; char r1; }statue1={"0","ABCDEFGHIJ"};
struct stares2{ int s; char r2; }statue2={"0","KLMNOPQRST"};
struct stares3{ int s; char r3; }statue3={'0","UVWXYZabcd"};
struct stares4{ int s; char r4; }statue4={"0","efghijklmn"};
struct stares5{ int s; char r5; }statue5={"0","opqrstuvwx"};
struct pidstatue{
char name;
intrenum;
intgiven;
intnogiven; } * capro;
capro->name = 'p1';capro->renum = 3;
capro->name = 'p2'; capro->renum = 2;
capro->name = 'p3'; capro->renum = 2;
capro->name = 'p4'; capro->renum = 4;
int sysgiven = 5;
Randomnum();
if(p1<0) {
printf(" fork error\n "); exit(); }
else if( (p1==0) || (p1==1) )
{if((capro->renum <= sysgiven) && (capro->nongive <= sysgiven))
{if((statue1->s=0)&&(capro->given<3)) { capro->given++;
sysgiven--; printf("%s\n",statue1->r1); statue1->s = 1; }
if((statue2->s=0)&&(capro->given<3)) { capro->given++;
sysgiven--; printf("%s\n",statue2->r2); statue2->s = 1; }
if((statue3->s=0)&&(capro->given<3)) { capro->given++;
sysgiven--; printf("%s\n",statue3->r3); statue3->s = 1; }
if((statue4->s=0)&&(capro->given<3)) { capro->given++;
sysgiven-- printf("%s\n",statue4->r4); statue4->s = 1; }
if((statue5->s=0)&&(capro->given<3)) { capro->given++;
sysgiven-- printf("%s\n",statue5->r5); statue5->s = 1 ; }
sysgiven = 5; exit();
} else printf(" Dead \n"); }
Randomnum();
if(p2<0){ printf(" fork error\n " ); exit(1); }
else if((p2==0) || (p2==1))
{ if((capro->renum <= sysgiven) && (capro->nongive <= sysgiven))
{ if((statue1->s=0)&&(capro->given<3)) { capro->given++;
sysgiven--; printf("%s\n",statue1->r1); statue1->s = 1; }
if((statue2->s=0)&&(capro->given<3)) { capro->given++;
sysgiven--; printf("%s\n",statue2->r2); statue2->s = 1; }
if((statue3->s=0)&&(capro->given<3)) { capro->given++;
sysgiven--; printf("%s\n",statue3->r3); statue3->s = 1; }
if((statue4->s=0)&&(capro->given<3)) { capro->given++;
sysgiven-- printf("%s\n",statue4->r4); statue4->s = 1; }
if((statue5->s=0)&&(capro->given<3)) { capro->given++;
sysgiven-- printf("%s\n",statue5->r5); statue5->s = 1 ; }
sysgiven = 5; exit(); } else printf(" Dead \n"); }
Randomnum();
if( p3<0 ) { printf(" fork error\n " ); exit(1); }
else if((p3==0) || (p3==1))
{ if((capro->renum <= sysgiven) && (capro->nongive <= sysgiven))
{ if((statue1->s=0)&&(capro->given<3)){ capro->given++;
sysgiven--; printf("%s\n",statue1->r1); statue1->s = 1; }
if((statue2->s=0)&&(capro->given<3)) { capro->given++;
sysgiven--; printf("%s\n",statue2->r2); statue2->s = 1; }
if((statue3->s=0)&&(capro->given<3)) { capro->given++;
sysgiven--; printf("%s\n",statue3->r3); statue3->s = 1; }
if((statue4->s=0)&&(capro->given<3)) { capro->given++;
sysgiven-- printf("%s\n",statue4->r4); statue4->s = 1; }
if((statue5->s=0)&&(capro->given<3)) { capro->given++;
sysgiven-- printf("%s\n",statue5->r5); statue5->s = 1 ; }
sysgiven = 5; exit(); }
else printf(" Dead \n"); }
Randomnum();
if( p4<0 ) { printf(" fork error\n " ); exit(1); }
else if((p4==0) || (p4==1))
{ if((capro->renum <= sysgiven) && (capro->nongive <= sysgiven))
{ if((statue1->s=0)&&(capro->given<3)) { capro->given++;
sysgiven--; printf("%s\n",statue1->r1); statue1->s = 1; }
if((statue2->s=0)&&(capro->given<3)) { capro->given++;
sysgiven--; printf("%s\n",statue2->r2); statue2->s = 1; }
if((statue3->s=0)&&(capro->given<3)) { capro->given++;
sysgiven--; printf("%s\n",statue3->r3); statue3->s = 1; }
if((statue4->s=0)&&(capro->given<3)) { capro->given++;
sysgiven-- printf("%s\n",statue4->r4); statue4->s = 1; }
if((statue5->s=0)&&(capro->given<3)) { capro->given++;
sysgiven-- printf("%s\n",statue5->r5); statue5->s = 1 ; }
sysgiven = 5; exit(); } else printf(" Dead \n"); }}
int Radomnum(void)
{ int i;
i = random();
i = i%4;
switch(i){
case 0 :p1 = fork(); break;
case 1 :p2 = fork(); break;
case 2 :p3 = fork(); break;
case 3 :p4 = fork(); break;
} return; } struct stares3{ int s; char r3; }statue3={'0","UVWXYZabcd"};
这里的'是不是有问题啊?应该是"。 这个已经 解决了 ! 语法错误 已经都解决了!
就是warnning
!
还有那个 运行时 提示: segmention fault
warnnig :assign makes interger from pointer without a cast 具体原因我也不知道。
我怀疑还是刚刚那一句(及其它类似的)有问题。
""里面是字符串的,它的实际内容是除了0之外后面还有个'\0'.
而你对它的定义是整型类型。
你看看把所有的"0"改成'0'看看行不行(我只知道字符型和整型可以互换,不知道字体串也可以和整型互换)。
呵呵,我很菜的,说得不对请别笑:) 我把 哪个 改了 : "0" -->gaiwei 0
但还是提示 !警告! char r3改为char r3呢?你后面赋值是照字符串赋的,除了十个字母之外还有一个'\0'啊。要不一个一个字母的赋值?
页:
[1]
2