在C中帮助这个程序 [英] Help in this programm in C

查看:214
本文介绍了在C中帮助这个程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。我在一段时间之前就开始学习程序语言C.我是在试图制作关于一个非常简单的卖店的程序。这个程序

没有任何编译问题,但当我运行它时,我面对其他一些我无法纠正的b $ b ploblems。如果有人拿一个

看看我会很感激我的程序是为了帮助我。我多次尝试找出

,我的错误在哪里,但我没办法处理。

我已经做了一些评论到程序,以使其更容易

容易。

关于我在程序中的写作风格的任何建议是

可接受。

请帮帮我!!!


程序

#include< stdio.h>

# include< stdlib.h>

#include< string.h>


/ *函数* /

int menu(void );

struct sells * insert(void);

struct sells * search(void);

int show(stru ct卖*清单);

int退出(无效);


/ *结构* /

struct sells {

char * tittle;

char * singer;

int price;

int count;

struct sells * next;

};


struct sells * list;

struct sells * alloc(void)

{

return(struct sells *)malloc(sizeof(struct sells));

}

/ *功能主* /

int main(无效)

{

menu();

返回0;

}


/ *功能菜单。在此功能中,用户有机会选择


他/他她想做* /

int菜单(无效)

{

int i;


printf(" --------- MENU --------- \ n");

printf(" Press \" 1 \ "插入数据\ n");

printf(" Press \" 2 \"来搜索数据\ n");

printf( 按下\和3按钮显示数据\ n");

printf("按\&4; \\以退出programm \ n" ;);

putchar(''\ n\ n'');


printf(" Make your choice\t);

scanf("%d",& i);


while((i< 1)&&(i> 4))

{

printf("你做错了选择。\\ n请新建

choice \ n);

scanf("%d"& i);

}


开关(i)

{

案例1:

{

insert();

休息;

}

案例2:

{

搜索();

休息;

}

案例3:

{

show(list);

break;

}

案例4:

{

退出();

休息;

}

}

返回i;

}


/ *在此功能中,用户插入数据。* /

struct sells * insert(void)

{

char titlos [15];

char tragoudisths [15];

int timi;

struct卖出* n;

浮动m_out;

int i;

m_out = 0;

printf (%f\ n,& m_out);

n = alloc();


printf("赠送CD的标题) \ n");

scanf("%s"& titlos);

getchar();

printf(" ;给出歌手的名字\ n");

scanf("%s"& tragoudisths);

getchar();


printf(给出CD \ n的价格);

scanf("%d"& timi);

getchar();


while((timi< 0)||(timi> 100))

{

printf(您输入了错误的价格。\ nGG我有一个新的

price.\\\
");

scanf("%d"& timi);

getchar( );

}

getchar();


n-> tittle = strdup(titlos);

n-> singer = strdup(tragoudisths);

n-> price = timi;


if(list == NULL)

{

list = alloc();

list-> tittle = strdup(n-> tittle);

list-> singer = strdup(n-> singer);

list-> price = n-> price;

list-> ; next = NULL;

printf("%f"& m_out);

}

else if((m_out =( strcmp(titlos,n-> tittle)))== 0)

{

list-> count ++;

printf(" ;%f"& m_out);

}

else if((m_out =(strcmp(titlos,n-> tittle)))< 0)

{

n = alloc();

n-> tittle = strdup(titlos);

n - > singer = strdup(tragoudisths);

n-> price = timi;

n-> count = 1;

n-> next = list;

list = n;


printf("%s \ t \ t%s \ t \ t%d \\\\ n ;,list-> tittle,list-> singer,list-> price);

}

else

{

list-> next = insert();

返回列表;

}

printf(" Press \\ \\" 1\"返回菜单或\" 2 \"退出\ n");

printf(做出你的选择);

scanf("%d",& i);


开关(i)

{

案例1:

{

menu();

休息;

}

案例2:

{

退出();

休息;

}

}

返回n;

}

/ *在此功能中,用户搜索元素。他也可以修改

吧。

如果有人可以我愿意想告诉我我要做什么,以便

删除一个元素。* /

struct sells * search(void)

{

char titlos [15];

int i,k,out;

char choice;


printf("给你想要找到的CD的那些东西);

得到(titlos);

getchar();

if(list == NULL ||(out = strcmp(list-> tittle,titlos))> 0)

{

printf (你想要的小东西不存在。。 );

printf(" Press \" 1 \"返回菜单或\" 2 \"退出\ n");

printf(做出你的选择);

scanf("%d",& i);


开关(i)

{

案例1:

{

menu();

休息;

}

案例2:

{

退出();

休息;

}

}

返回列表;

}

else if(out == 0)

{

printf(" Tittle:\ t%s \ n) ;,list-> tittle);

printf("歌手:\ t%s \ n",list->歌手);

printf( 价格:\t%d \ n,列表 - >价格);


printf(你想做任何改变; \ n) ;

printf(如果是,请按\" 1 \" else \" 0 \返回

menu \ n ;);

printf(自己做出选择);

scanf("%d"& k);

开关(k)

{

案例1:

{

printf(你想要不改变它们; \ n按Y(是)

或N(NO)\ t);

scanf("%s",& choice);

getchar();

if(choice ==''Y'')

{

printf(" Give new tittle:\ n");

得到(list-> tittle);

getchar();

}

printf("你要不要更改

歌手的名字; \ n按Y (是)或N(否)\t);

scanf("%s",& choice);

getchar();

if(choice ==''Y'')

{

printf(" Give new name:\ n");

得到(list->歌手);

getchar();

}

printf("你想要吗?更改

CD的价格; \ n按Y(是)或N(否)\t);

scanf("%s", & choice);

getchar();

if(choice ==''Y'')

{

printf(给新价格:\\ n");

scanf("%d"& list-> price);

while((list-> price< 0)& &(list-> price> 100))

{

printf("您输错了价格。\给一个新的

price.\\\
");

scanf("%d",& list-> price);

}

putchar(''\ n'');

}

休息;

}

案例0:

{

menu();

break;

}

}

}

返回列表;

}

/ *向用户显示所有元素的函数已经

插入。

在这个函数中有一个问题。当我插入更多3个元素时,

这些元素没有''在我看来。我认为问题出在我的

插入

但是我不太确定。* /

int show( struct sells * list)

{

int i,k;

k = 1;

printf(" \t\\ t -------列表-------- \\\
");

printf(" Num\t\tTittle\t\ tSinger \ t \tPrice \ n");

while(list!= NULL)

{


printf(" %d\t%s\t\t%s\t\t%d\t\t\\\
",K,列表 - >丝毫不差,列表 - >歌手,列表 - >价格);


k ++;

list = list-> next;

}

printf(你想做什么?);

printf(" Press \" 1 \"返回菜单或\2 \退出\ n");

printf(做出你的选择);

scanf("%d",& i);


开关(i)

{

案例1:

{

menu();

休息;

}

案例2:

{

退出();

休息;

}

}

返回0;

}


/ *退出程序* /

int退出(无效)

{

int i;


printf(你真的想退出程序; \ n);

printf("如果是,请按\" 1 \" else \" 0 \" \ n");

printf(" Make your choice");

scanf("%d",& i);


开关(i)

{

案例1:

{

menu();

休息;

}

案例2:

{

休息;

}

返回0;

}

}

Hi.I am started learning Programm language C before some time.I am
trying to make a programm about a very simple "sell shop".This programm
hasn''t got any compile problem but when i run it i face some other
ploblems which i can not correct.I would appreciated if someone take a
look at my programm so as to help me.I tried many times to find out
where my mistakes are but i didn''t manage something.
I have made some comments due to the programm so as to make it more
easy to as.
Any recommendations about my writing style in the programm are
acceptable.
Please help me!!!

Programm
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

/* Functions*/
int menu(void);
struct sells *insert(void);
struct sells *search(void);
int show(struct sells *list);
int exit(void);

/*Struct*/
struct sells{
char *tittle;
char *singer;
int price;
int count;
struct sells *next;
};

struct sells *list;
struct sells *alloc(void)
{
return(struct sells*)malloc(sizeof(struct sells));
}
/*Function main*/
int main(void)
{
menu();
return 0;
}

/*Function menu.In this function the user has the opportunity to choose

what he/she want to do*/
int menu(void)
{
int i;

printf("---------MENU---------\n");
printf("Press \"1\" to insert data\n");
printf("Press \"2\" to search data\n");
printf("Press \"3\" to show data\n");
printf("Press \"4\" to exit from programm\n");
putchar(''\n\n'');

printf("Make your choice\t");
scanf("%d",&i);

while((i<1)&&(i>4))
{
printf("You made wrong choice.\nPlease make a new
choice\n");
scanf("%d",&i);
}

switch(i)
{
case 1:
{
insert();
break;
}
case 2:
{
search();
break;
}
case 3:
{
show(list);
break;
}
case 4:
{
exit();
break;
}
}
return i;
}

/*In this function the user insert the data.*/
struct sells *insert(void)
{
char titlos[15];
char tragoudisths[15];
int timi;
struct sells *n;
float m_out;
int i;
m_out=0;
printf("%f\n",&m_out);
n=alloc();

printf("Give the title of the CD\n");
scanf("%s",&titlos);
getchar();
printf("Give the name of the singer\n");
scanf("%s",&tragoudisths);
getchar();

printf("Give the price of the CD\n");
scanf("%d",&timi);
getchar();

while((timi<0)||(timi>100))
{
printf("You have insert a wrong price.\nGive a new
price.\n");
scanf("%d",&timi);
getchar();
}
getchar();

n->tittle=strdup(titlos);
n->singer=strdup(tragoudisths);
n->price=timi;

if(list==NULL)
{
list=alloc();
list->tittle=strdup(n->tittle);
list->singer=strdup(n->singer);
list->price=n->price;
list->next=NULL;
printf("%f",&m_out);
}
else if((m_out=(strcmp(titlos,n->tittle)))==0)
{
list->count++;
printf("%f",&m_out);
}
else if((m_out=(strcmp(titlos,n->tittle)))<0)
{
n=alloc();
n->tittle=strdup(titlos);
n->singer=strdup(tragoudisths);
n->price=timi;
n->count=1;
n->next=list;
list=n;

printf("%s\t\t%s\t\t%d\t\t\n",list->tittle,list->singer,list->price);
}
else
{
list->next=insert();
return list;
}
printf("Press \"1\" to return to menu or \"2\" to exit\n");
printf("Make your choice");
scanf("%d",&i);

switch(i)
{
case 1:
{
menu();
break;
}
case 2:
{
exit();
break;
}
}
return n;
}
/*In this function the user search for an element.Also he can modify
it.
If someone can i would like to tell me what i have to do so as to
delete an element.*/
struct sells *search(void)
{
char titlos[15];
int i,k,out;
char choice;

printf("Give the tittle of the CD that you want to find\n");
gets(titlos);
getchar();
if(list==NULL||(out=strcmp(list->tittle,titlos))>0)
{
printf("The tittle that you want doesn''t exist.\n");
printf("Press \"1\" to return to menu or \"2\" to exit\n");
printf("Make your choice");
scanf("%d",&i);

switch(i)
{
case 1:
{
menu();
break;
}
case 2:
{
exit();
break;
}
}
return list;
}
else if(out==0)
{
printf("Tittle: \t%s\n",list->tittle);
printf("Singer: \t%s\n",list->singer);
printf("Price: \t%d\n",list->price);

printf("Do you want to make any change;\n");
printf("If Yes press \"1\" else \"0\" to return to
menu\n");
printf("Make your choice");
scanf("%d",&k);
switch(k)
{
case 1:
{
printf("Do you want ot change the tittle;\nPress Y(YES)
or N(NO)\t");
scanf("%s",&choice);
getchar();
if(choice==''Y'')
{
printf("Give new tittle:\n");
gets(list->tittle);
getchar();
}
printf("Do you want ot change the name of the
singer;\nPress Y(YES) or N(NO)\t");
scanf("%s",&choice);
getchar();
if(choice==''Y'')
{
printf("Give new name:\n");
gets(list->singer);
getchar();
}
printf("Do you want ot change the price of the
CD;\nPress Y(YES) or N(NO)\t");
scanf("%s",&choice);
getchar();
if(choice==''Y'')
{
printf("Give new price:\n");
scanf("%d",&list->price);
while((list->price<0)&&(list->price>100))
{
printf("You have insert a wrong price.\nGive a new
price.\n");
scanf("%d",&list->price);
}
putchar(''\n'');
}
break;
}
case 0:
{
menu();
break;
}
}
}
return list;
}
/*Function which shows to the user all the element that has already
insert.
In this functio there is a problem.When i insert more the 3 elements,
these elements doesn''t appear to me.I think that the problem is in my
insert
but i am not quite sure.*/
int show(struct sells *list)
{
int i,k;
k=1;
printf("\t\t-------LIST--------\n");
printf("Num\t\tTittle\t\tSinger\t\tPrice\n");
while(list!=NULL)
{

printf("%d\t%s\t\t%s\t\t%d\t\t\n",k,list->tittle,list->singer,list->price);

k++;
list=list->next;
}
printf("What do you want to do\n");
printf("Press \"1\" to retutn to menu or \"2\" to exit\n");
printf("Make your choice");
scanf("%d",&i);

switch(i)
{
case 1:
{
menu();
break;
}
case 2:
{
exit();
break;
}
}
return 0;
}

/*Exit from the programm*/
int exit(void)
{
int i;

printf("Do you really want to exit from the programm;\n");
printf("If Yes press \"1\" else \"0\"\n");
printf("Make your choice");
scanf("%d",&i);

switch(i)
{
case 1:
{
menu();
break;
}
case 2:
{
break;
}
return 0;
}
}

推荐答案

de ***** @ hotmail.com 说:

嗨。我在一段时间之前开始学习Programm语言C.我是

试图制作关于a的程序非常简单的卖店。这个程序

没有任何编译问题
Hi.I am started learning Programm language C before some time.I am
trying to make a programm about a very simple "sell shop".This programm
hasn''t got any compile problem



我不同意。见下文。修复这个,从第一个开始,然后

回到我们。


(注意:在下面的诊断报告中,行号可能不同

略微对你来源的人来说。)


gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align

-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes

-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef

-Wnested-externs -Wcast -qual -Wshadow -Wconversion -Wwrite-strings

-Wno-conversion -ffloat-store -O2 -g -pg -c -o foo.o foo.c

foo.c:10:退出的冲突类型'

/usr/include/stdlib.h:577:之前的'退出'声明'

foo.c :26:警告:以前没有`alloc'的原型'

foo.c:在函数`menu'':

foo.c:52:警告:多 - 字符字符常量

foo.c:59:警告:未知转义序列`\''

foo.c:函数`insert'':

foo.c:102:警告:双格式,指针arg(arg 2)

foo.c:105:警告:char格式,不同类型arg(arg 2)

foo.c:108:警告:字符格式,不同类型arg(arg 2)

foo.c:115:警告:未知转义序列`\''

foo.c:116:警告:未知转换类型字符'''格式

foo.c:116:警告:格式参数太多

foo.c:120:警告:隐式声明函数`strdup''

foo.c:120:警告:赋值使得整数指针没有强制转换

foo.c:121:警告:赋值从整数中生成没有强制转换的指针

foo.c:126:警告:赋值使得整数指针没有强制转换

foo。 c:127:警告:赋值从整数中生成没有强制转换的指针

foo.c:130:警告:双格式,指针arg(arg 2)

foo.c :135:警告:双格式,指针arg(arg 2)

foo.c:140:警告:assi gnment在没有强制转换的情况下从整数中生成指针

foo.c:141:警告:赋值从整数中生成指针而没有强制转换

foo.c:在函数search中:

foo.c:214:警告:未知转义序列`\''

foo.c:222:警告:未知转义序列`\''

foo.c:223:警告:格式未知的转换类型字符'''

foo.c:223:警告:格式的参数太多

foo.c:232:警告:未知转义序列`\''

foo.c:242:警告:未知转义序列`\''

foo.c:252:警告:未知转义序列`\''

foo.c:253:警告:未知转换类型字符'''格式

foo.c:253:警告:格式的参数太多

foo.c:顶级:

foo.c:276:警告:声明`list' '影子全球宣言

foo.c:在函数`show'':

foo.c:277:警告:声明`list''阴影全局声明

foo.c:在函数`exit'':

foo.c:335:警告:控制到达结束无效功能

make:*** [foo.o]错误1


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然放弃了www)

I beg to differ. See below. Fix this lot, starting with the first, and then
get back to us.

(Caution: in the following diagnostic report, line numbers may differ
slightly to those in your source.)

gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2 -g -pg -c -o foo.o foo.c
foo.c:10: conflicting types for `exit''
/usr/include/stdlib.h:577: previous declaration of `exit''
foo.c:26: warning: no previous prototype for `alloc''
foo.c: In function `menu'':
foo.c:52: warning: multi-character character constant
foo.c:59: warning: unknown escape sequence `\ ''
foo.c: In function `insert'':
foo.c:102: warning: double format, pointer arg (arg 2)
foo.c:105: warning: char format, different type arg (arg 2)
foo.c:108: warning: char format, different type arg (arg 2)
foo.c:115: warning: unknown escape sequence `\ ''
foo.c:116: warning: unknown conversion type character ` '' in format
foo.c:116: warning: too many arguments for format
foo.c:120: warning: implicit declaration of function `strdup''
foo.c:120: warning: assignment makes pointer from integer without a cast
foo.c:121: warning: assignment makes pointer from integer without a cast
foo.c:126: warning: assignment makes pointer from integer without a cast
foo.c:127: warning: assignment makes pointer from integer without a cast
foo.c:130: warning: double format, pointer arg (arg 2)
foo.c:135: warning: double format, pointer arg (arg 2)
foo.c:140: warning: assignment makes pointer from integer without a cast
foo.c:141: warning: assignment makes pointer from integer without a cast
foo.c: In function `search'':
foo.c:214: warning: unknown escape sequence `\ ''
foo.c:222: warning: unknown escape sequence `\ ''
foo.c:223: warning: unknown conversion type character ` '' in format
foo.c:223: warning: too many arguments for format
foo.c:232: warning: unknown escape sequence `\ ''
foo.c:242: warning: unknown escape sequence `\ ''
foo.c:252: warning: unknown escape sequence `\ ''
foo.c:253: warning: unknown conversion type character ` '' in format
foo.c:253: warning: too many arguments for format
foo.c: At top level:
foo.c:276: warning: declaration of `list'' shadows global declaration
foo.c: In function `show'':
foo.c:277: warning: declaration of `list'' shadows global declaration
foo.c: In function `exit'':
foo.c:335: warning: control reaches end of non-void function
make: *** [foo.o] Error 1

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)


de ***** @ hotmail.com napsal(a):
de*****@hotmail.com napsal(a):

Hi.I am started在一段时间之前学习程序语言C.我是一个非常简单的销售商店的程序。我这个程序

没有任何编译问题,但当我运行它时,我面对其他一些我无法纠正的问题。如果有人拿一个

看看我的程序以便帮助我,我将不胜感激。我多次尝试找出

我的错误但是我没有管理。

由于程序设计我做了一些评论以便制作它更多

易于使用。

关于我在程序中的写作风格的任何建议都是

acc eptable。
Hi.I am started learning Programm language C before some time.I am
trying to make a programm about a very simple "sell shop".This programm
hasn''t got any compile problem but when i run it i face some other
ploblems which i can not correct.I would appreciated if someone take a
look at my programm so as to help me.I tried many times to find out
where my mistakes are but i didn''t manage something.
I have made some comments due to the programm so as to make it more
easy to as.
Any recommendations about my writing style in the programm are
acceptable.



编码风格?是的,尝试使用缩进方式如下:

缩进-npro -kr -i8 -ts8 -sob -l80 -ss -ncs

(un * x实用程序)缩进)

Coding style? yes, try to use indent in way such this one:
indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs
(un*x utility for indentation)


请帮帮我!!!


程序


#include< stdio.h>

#include< stdlib.h>

#include< string.h>


/ *函数* /

int menu(void);

struct sells * insert(void);

struct sells * search(void);

int show(struct sells * list);

int exit(void);


/ * Struct * /

struct卖{

char * tittle;

char * singer;

int price;

int count;

struct sells * next;

};


struct sells * list;


struct sells * alloc(void)

{

return(struct sells *)malloc(sizeof(struct sells));
Please help me!!!

Programm
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

/* Functions*/
int menu(void);
struct sells *insert(void);
struct sells *search(void);
int show(struct sells *list);
int exit(void);

/*Struct*/
struct sells{
char *tittle;
char *singer;
int price;
int count;
struct sells *next;
};

struct sells *list;
struct sells *alloc(void)
{
return(struct sells*)malloc(sizeof(struct sells));



你不需要施放。

you don''t need to cast.


}


/ *功能主* /

int main(无效)

{

menu();

返回0;

}


/ *功能菜单。在此功能中,用户有机会选择


他/她想做什么* /

int menu(无效)

{

int i;
< br $> b $ b printf(" --------- MENU --------- \ n");

printf(" Press \\ \\1 \以插入数据\ n");

printf(" Press \" 2 \"来搜索数据\ n);

printf("按\" 3 \"显示数据\ n");

printf(" Press \" 4 \" ;退出programm \ n");
}
/*Function main*/
int main(void)
{
menu();
return 0;
}

/*Function menu.In this function the user has the opportunity to choose

what he/she want to do*/
int menu(void)
{
int i;

printf("---------MENU---------\n");
printf("Press \"1\" to insert data\n");
printf("Press \"2\" to search data\n");
printf("Press \"3\" to show data\n");
printf("Press \"4\" to exit from programm\n");



您可以使用看跌期权。

You may use puts for these.


putchar(''\ n\ n' ');


printf(" Make your choice\t);

scanf("%d",& i); <同时((i< 1)&&(i> 4))

{

printf(" You)做错了选择。请让新的

选择\ n");

scanf("%d",& i);

}


开关(i)

{

案例1:

{

insert();

休息;

}

案例2:

{

搜索();

休息;

}

案例3:

{

显示(列表);

休息;

}

案例4:

{

退出();

休息;

}

}

返回i;

}


/ *在此函数中,用户插入数据。* /

struct sells * insert (无效)

{

char titlos [15];

char tragoudisths [15];

int timi ;

struct sells * n;

float m_out;

int i;

m_out = 0;
putchar(''\n\n'');

printf("Make your choice\t");
scanf("%d",&i);

while((i<1)&&(i>4))
{
printf("You made wrong choice.\nPlease make a new
choice\n");
scanf("%d",&i);
}

switch(i)
{
case 1:
{
insert();
break;
}
case 2:
{
search();
break;
}
case 3:
{
show(list);
break;
}
case 4:
{
exit();
break;
}
}
return i;
}

/*In this function the user insert the data.*/
struct sells *insert(void)
{
char titlos[15];
char tragoudisths[15];
int timi;
struct sells *n;
float m_out;
int i;
m_out=0;



你可以做浮动m_out = 0;

you can do float m_out = 0;


printf("%f\\\
" ,& m_out);

n = alloc();
printf("%f\n",&m_out);
n=alloc();



检查是否为空。

check for NULL.


>

printf("给出CD \ n)的标题;

scanf("%s"& titlos);
>
printf("Give the title of the CD\n");
scanf("%s",&titlos);



这很容易出错。如果我输入char 15,它就会崩溃。

另一件事,打开警告,它会告诉你,这很糟糕。

titlos尚未指针,所以scanf("%s",titlos);是正确的,

This is bug-prone. If I enter char 15, it will crash.
Another thing, turn on warnings, it would tell you, it''s bad.
titlos is pointer yet, so scanf("%s", titlos); is correct,


getchar();


printf("给出歌手的名字\ n) ;

scanf("%s"& tragoudisths);
getchar();
printf("Give the name of the singer\n");
scanf("%s",&tragoudisths);



....

....


getchar();


printf(给出CD的价格);

scanf("%d"& timi);

getchar() ;


while((timi< 0)||(timi> 100))

{

printf(" You插入错误的价格。\\ n给予新的

price.\ n;;

scanf("%d",& timi);

getchar();

}

getchar();


n-> tittle = strdup (titlos);

n-> singer = strdup(tragoudisths);
getchar();

printf("Give the price of the CD\n");
scanf("%d",&timi);
getchar();

while((timi<0)||(timi>100))
{
printf("You have insert a wrong price.\nGive a new
price.\n");
scanf("%d",&timi);
getchar();
}
getchar();

n->tittle=strdup(titlos);
n->singer=strdup(tragoudisths);



NULL处理

NULLs handling


n-> price = timi;


if(list == NULL)

{

list = alloc();
n->price=timi;

if(list==NULL)
{
list=alloc();



再次

again


list-> tittle = strdup(n-> tittle);

list-> singer = strdup(n-> singer);

list-> price = n-> price;

list - > next = NULL;

printf("%f",& m_out);
list->tittle=strdup(n->tittle);
list->singer=strdup(n->singer);
list->price=n->price;
list->next=NULL;
printf("%f",&m_out);



为什么指针?

why pointer?


}

else if((m_out = (strcmp(titlos,n-> tittle)))== 0)

{

list-> count ++;

printf( "%F",&安培; m_out);
}
else if((m_out=(strcmp(titlos,n->tittle)))==0)
{
list->count++;
printf("%f",&m_out);



....

....


}

else if((m_out =(strcmp(titlos,n-> tittle)))< 0)

{

n = alloc();
}
else if((m_out=(strcmp(titlos,n->tittle)))<0)
{
n=alloc();



....

....


n-> tittle = strdup(titlos);

n-> singer = strdup(tragoudisths);

n-> price = timi;

n-> count = 1;

n-> next = list;

list = n;


printf("%s \ t \ t %s \ t \\\%d \\\\ n \\ n,列表 - > tittle,list-> singer,list-> price);

}

其他

{

list-> next = insert();

返回列表;

}

printf("按\" 1 \"返回菜单或按\" 2 \"退出\ n");

printf(做出你的选择);

scanf("%d",& i);


开关(i)

{

案例1:

{

menu();

休息;

}

案例2:

{

退出();

休息;

}

}

返回n;

}


/ *在此函数中,用户搜索元素。他也可以修改



如果有人可以告诉我我必须做什么,以便

删除一个元素。* /

struct sells *搜索(无效)

{

char titlos [15];

int i,k,out;

char的选择;


printf(给你想要找到的CD的小部分);

得到(titlos);

getchar();

if(list == NULL ||(out = strcmp(list-> tittle,titlos))> 0)

{

printf(你想要的小东西不存在。\ n);

printf(" Press \\ \\" 1\"返回菜单或\" 2 \"退出\ n");

printf(做出你的选择);

scanf("%d",& i);


开关(i)

{

案例1:

{

menu();

休息;

}

案例2:

{

退出();

休息;

}

}

返回列表;

}

else if(out == 0)

{

printf(" Tittle:\ t%s \ n) ;,list-> tittle);

printf("歌手:\ t%s \ n",list->歌手);

printf( 价格:\t%d \ n ,list-> price);


printf(你想做任何改变; \ n);

printf("如果是,请按\1 \别的\" 0 \"返回

menu \ n");

printf(" Make your choice");

scanf("%d" ;,& k);

开关(k)

{

案例1:

{

printf(你想要不改变它们; \ n按Y(是)

或N(NO)\ t);

scanf("%s",& choice);

getchar();

if(choice ==''Y'')

{

printf(" Give new tittle:\ n");

得到(list-> tittle);

getchar();

}

printf("你要不要更改

歌手的名字; \ n按Y (是)或N(否)\t);

scanf("%s",& choice);

getchar();

if (选择==''Y'')

{

printf("新名称:\ n");

获取(list-> singer);

getchar();

}

printf("你要不要改变价格

CD; \ n按Y(是)或N(否)\t");

scanf("%s",& choice);

getchar();

if(choice ==''Y'')

{

printf(" ;给新价格:\ n");

scanf("%d"& list->价格);

while((list-> ;价格< 0)&&(list->价格> 100))

{
n->tittle=strdup(titlos);
n->singer=strdup(tragoudisths);
n->price=timi;
n->count=1;
n->next=list;
list=n;

printf("%s\t\t%s\t\t%d\t\t\n",list->tittle,list->singer,list->price);
}
else
{
list->next=insert();
return list;
}
printf("Press \"1\" to return to menu or \"2\" to exit\n");
printf("Make your choice");
scanf("%d",&i);

switch(i)
{
case 1:
{
menu();
break;
}
case 2:
{
exit();
break;
}
}
return n;
}
/*In this function the user search for an element.Also he can modify
it.
If someone can i would like to tell me what i have to do so as to
delete an element.*/
struct sells *search(void)
{
char titlos[15];
int i,k,out;
char choice;

printf("Give the tittle of the CD that you want to find\n");
gets(titlos);
getchar();
if(list==NULL||(out=strcmp(list->tittle,titlos))>0)
{
printf("The tittle that you want doesn''t exist.\n");
printf("Press \"1\" to return to menu or \"2\" to exit\n");
printf("Make your choice");
scanf("%d",&i);

switch(i)
{
case 1:
{
menu();
break;
}
case 2:
{
exit();
break;
}
}
return list;
}
else if(out==0)
{
printf("Tittle: \t%s\n",list->tittle);
printf("Singer: \t%s\n",list->singer);
printf("Price: \t%d\n",list->price);

printf("Do you want to make any change;\n");
printf("If Yes press \"1\" else \"0\" to return to
menu\n");
printf("Make your choice");
scanf("%d",&k);
switch(k)
{
case 1:
{
printf("Do you want ot change the tittle;\nPress Y(YES)
or N(NO)\t");
scanf("%s",&choice);
getchar();
if(choice==''Y'')
{
printf("Give new tittle:\n");
gets(list->tittle);
getchar();
}
printf("Do you want ot change the name of the
singer;\nPress Y(YES) or N(NO)\t");
scanf("%s",&choice);
getchar();
if(choice==''Y'')
{
printf("Give new name:\n");
gets(list->singer);
getchar();
}
printf("Do you want ot change the price of the
CD;\nPress Y(YES) or N(NO)\t");
scanf("%s",&choice);
getchar();
if(choice==''Y'')
{
printf("Give new price:\n");
scanf("%d",&list->price);
while((list->price<0)&&(list->price>100))
{



不需要{}

unneeded { }


printf("您输入了错误的价格。\\ n给了一个新的
price.\ n);

scanf("%d"& list-> price);

}

putchar(''\ n'');

}

休息;

}

案例0:

{

menu();

休息;

}

}

}

返回列表;

}


/ *向用户显示已经

insert的所有元素的函数。 />
在这个函数中有一个问题。当我插入更多的3个元素时,

这些元素对我来说不会出现。我认为问题出在我的身上/>
插入

但我不太确定。* /

int show(struct sells * list)

{

int i,k;

k = 1;

printf(" \t\t -------列表 - ------- \ n");

printf(" Num\t\tTittle\t\tSinger\t\tPrice\\\
);

while(list!= NULL)

{


printf("%d \ t%s \ t \ t%s \\\\\\\\\\\\\\\\\ n",k,list-> tittle,list-> singer,list-> price);


k ++;

list = list- >下一个;

}

printf(你想做什么?);

printf(" Press \" 1\"返回菜单或\2 \退出\ n");

printf(做出你的选择);

scanf("%d",& i);


开关(i)

{

案例1:

{

menu();

休息;

}

案例2:

{

退出();

休息;

}

}

返回0;

}


/ *退出程序* /

int退出(无效)

{

int i;


printf(你真的想退出程序; \ n);

printf("如果是,请按\" 1 \" else \" 0 \" \ n");

printf(做出你的选择);

scanf("%d",& i);


switch(i)

{

案例1:

{

menu();

break;

}

案例2:

{

休息;

}
printf("You have insert a wrong price.\nGive a new
price.\n");
scanf("%d",&list->price);
}
putchar(''\n'');
}
break;
}
case 0:
{
menu();
break;
}
}
}
return list;
}
/*Function which shows to the user all the element that has already
insert.
In this functio there is a problem.When i insert more the 3 elements,
these elements doesn''t appear to me.I think that the problem is in my
insert
but i am not quite sure.*/
int show(struct sells *list)
{
int i,k;
k=1;
printf("\t\t-------LIST--------\n");
printf("Num\t\tTittle\t\tSinger\t\tPrice\n");
while(list!=NULL)
{

printf("%d\t%s\t\t%s\t\t%d\t\t\n",k,list->tittle,list->singer,list->price);

k++;
list=list->next;
}
printf("What do you want to do\n");
printf("Press \"1\" to retutn to menu or \"2\" to exit\n");
printf("Make your choice");
scanf("%d",&i);

switch(i)
{
case 1:
{
menu();
break;
}
case 2:
{
exit();
break;
}
}
return 0;
}

/*Exit from the programm*/
int exit(void)
{
int i;

printf("Do you really want to exit from the programm;\n");
printf("If Yes press \"1\" else \"0\"\n");
printf("Make your choice");
scanf("%d",&i);

switch(i)
{
case 1:
{
menu();
break;
}
case 2:
{
break;
}



为什么要在退出时再次调用菜单?调用exit(0);,但之前清理。

Why you call menu again, when you want to exit? Call exit(0);, but cleanup before.


返回0;

}

}
return 0;
}
}



-

js


--
js


On Fri,07 Jul 2006 08:38: 54 +0000,Richard Heathfield

< in ***** @ invalid.invalidwrote:
On Fri, 07 Jul 2006 08:38:54 +0000, Richard Heathfield
<in*****@invalid.invalidwrote:

> de **** *@hotmail.com说:
>de*****@hotmail.com said:

>嗨。我在一段时间之前开始学习Programm语言C.我正在尝试制作一个关于程序的程序一个非常简单的卖店。这个程序没有任何编译问题
>Hi.I am started learning Programm language C before some time.I am
trying to make a programm about a very simple "sell shop".This programm
hasn''t got any compile problem


我不敢苟同。见下文。 Fix this lot, starting with the first, and then
get back to us.

(Caution: in the following diagnostic report, line numbers may differ
slightly to those in your source.)

gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2 -g -pg -c -o foo.o foo.c


I beg to differ. See below. Fix this lot, starting with the first, and then
get back to us.

(Caution: in the following diagnostic report, line numbers may differ
slightly to those in your source.)

gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2 -g -pg -c -o foo.o foo.c



And then top it off with a run through PC-lint from
http://www.gimpel.com/ (warnings like 525 are supressed, and line

numbers may differ slightly to those in your source):


PC-lint for C/C++ (NT) Vers. 8.00u, Copyright Gimpel Software

1985-2006


--- Module: stdc.c (C)

_

int exit(void);

stdc.c(10) : Error 18: Symbol ’’exit(int)’’ redeclared (void/nonvoid,

arg. count) conflicts with line 261, file stdlib.h

stdlib.h(261) : Info 830: Location cited in prior message

_

int exit(void);

stdc.c(10) : Warning 532: Return mode of function ’’exit(int)’’

inconsistent with line 261, file stdlib.h

stdlib.h(261) : Info 830: Location cited in prior message

_

menu();

stdc.c(33) : Warning 534: Ignoring return value of function

’’menu(void)’’ (compare with line 6)

stdc.c(6) : Info 830: Location cited in prior message

_

#... = (char)((’’\n\n’’))) : _flsbuf(((’’\n\n’’)),((&_iob[1])))) /*lint

-restore *

#... (’’\n\n’’),stdout)

putchar(’’\n\n’’);

stdc.c(51) : Info 742: Multiple character constant

_

#... _flsbuf(((’’\n\n’’)),((&_iob[1])))) /*lint -restore */

#... (’’\n\n’’),stdout)

putchar(’’\n\n’’);

stdc.c(51) : Info 742: Multiple character constant

_

insert();

stdc.c(66) : Warning 534: Ignoring return value of function

’’insert(void)’’ (compare with line 7)

stdc.c(7) : Info 830: Location cited in prior message

_

search();

stdc.c(71) : Warning 534: Ignoring return value of function

’’search(void)’’ (compare with line 8)

stdc.c(8) : Info 830: Location cited in prior message

_

show(list);

stdc.c(76) : Warning 534: Ignoring return value of function

’’sh ow(struct sells *)’’ (compare with line 9)

stdc.c(9) : Info 830: Location cited in prior message

_

exit();

stdc.c(81) : Error 118: Too few arguments (0) for prototype

’’exit(int)’’

_

}

stdc.c(84) : Info 744: switch statement has no default

_

printf("%f\n",&m_out);

stdc.c(100) : Warning 559: Size of argument no. 2 inconsistent with

format

_

scanf("%s",&titlos);

stdc.c(104) : Warning 545: Suspicious use of &

stdc.c(104) : Warning 561: (arg. no. 2) indirect object inconsistent

with format

_

getchar();

stdc.c(105) : Warning 534: Ignoring return value of function

’’_filbuf(struct _iobuf *)’’ (compare with line 275, file stdio.h)

stdio.h(275) : Info 830: Location cited in prior message

_

scanf("%s",&tragoudisths);

stdc.c(109) : Warning 545: Suspicious use of &

stdc.c(109) : Warning 561: (arg. no. 2) indirect object inconsistent

with format

_

getchar();

stdc.c(110) : Warning 534: Ignoring return value of function

’’_filbuf(struct _iobuf *)’’ (compare with line 275, file stdio.h)

stdio.h(275) : Info 830: Location cited in prior message

_

getchar();

stdc.c(114) : Warning 534: Ignoring return value of function

’’_filbuf(struct _iobuf *)’’ (compare with line 275, file stdio.h)

stdio.h(275) : Info 830: Location cited in prior message

_

getchar();

stdc.c(120) : Warning 534: Ignoring return value of function

’’_filbuf(struct _iobuf *)’’ (compare with line 275, file stdio.h)

stdio.h(275) : Info 830: Location cited in prior message

_

getchar();

stdc.c(122) : Warning 534: Ignoring return value of function

’’_filbuf(struct _iobuf *)’’ (compare with line 275, file stdio.h)

stdio.h(275) : Info 830: Location cited in prior message

_

printf("%f",&m_out);

stdc.c(135) : Warning 559: Size of argument no. 2 inconsistent with

format

_

printf("%f",&m_out);

stdc.c(140) : Warning 559: Size of argument no. 2 inconsistent with

format

_

printf("Press \"1\" to return to menu or \"2\" to exit\n");

stdc.c(159) : Warning 539: Did not expect positive indentation from

line 154

stdc.c(154) : Info 830: Location cited in prior message

_

printf("Press \"1\" to return to menu or \"2\" to exit\n");

stdc.c(159) : Warning 539: Did not expect positive indentation from

line 142

stdc.c(142) : Info 830: Location cited in prior message

_

printf("Press \"1\" to return to menu or \"2\" to exit\n");

stdc.c(159) : Warning 539: Did not expect positive indentation from

line 137

stdc.c(137) : Info 830: Location cited in prior message

_

menu();

stdc .c(167) : Warning 534: Ignoring return value of function

’’menu(void)’’ (compare with line 42)

stdc.c(42) : Info 830: Location cited in prior message

_

exit();

stdc.c(172) : Error 118: Too few arguments (0) for prototype

’’exit(int)’’

_

}

stdc.c(175) : Info 744: switch statement has no default

_

gets(titlos);

stdc.c(191) : Warning 534: Ignoring return value of function

’’gets(char *)’’ (compare with line 324, file stdio.h)

stdio.h(324) : Info 830: Location cited in prior message

_

gets(titlos);

stdc.c(191) : Warning 421: Caution -- function ’’gets(char *)’’ is

considered dangerous

_

getchar();

stdc.c(192) : Warning 534: Ignoring return value of function

’’_filbuf(struct _iobuf *)’’ (compare with line 275, fil e stdio.h)

stdio.h(275) : Info 830: Location cited in prior message

_

menu();

stdc.c(204) : Warning 534: Ignoring return value of function

’’menu(void)’’ (compare with line 42)

stdc.c(42) : Info 830: Location cited in prior message

_

exit();

stdc.c(209) : Error 118: Too few arguments (0) for prototype

’’exit(int)’’

_

}

stdc.c(212) : Info 744: switch statement has no default

_

getchar();

stdc.c(231) : Warning 534: Ignoring return value of function

’’_filbuf(struct _iobuf *)’’ (compare with line 275, file stdio.h)

stdio.h(275) : Info 830: Location cited in prior message

_

gets(list->tittle);

stdc.c(235) : Warning 534: Ignoring return value of function

’’gets(char *)’’ (compare with line 324, file stdio.h)

stdio.h(324) : Info 830: Location cited in prior message

_

gets(list->tittle);

stdc.c(235) : Warning 421: Caution -- function ’’gets(char *)’’ is

considered dangerous

_

getchar();

stdc.c(236) : Warning 534: Ignoring return value of function

’’_filbuf(struct _iobuf *)’’ (compare with line 275, file stdio.h)

stdio.h(275) : Info 830: Location cited in prior message

_

getchar();

stdc.c(240) : Warning 534: Ignoring return value of function

’’_filbuf(struct _iobuf *)’’ (compare with line 275, file stdio.h)

stdio.h(275) : Info 830: Location cited in prior message

_

gets(list->singer);

stdc.c(244) : Warning 534: Ignoring return value of function

’’gets(char *)’’ (compare with line 324, file stdio.h)

stdio.h(324) : Info 830: Location cited in prior me ssage

_

gets(list->singer);

stdc.c(244) : Warning 421: Caution -- function ’’gets(char *)’’ is

considered dangerous

_

getchar();

stdc.c(245) : Warning 534: Ignoring return value of function

’’_filbuf(struct _iobuf *)’’ (compare with line 275, file stdio.h)

stdio.h(275) : Info 830: Location cited in prior message

_

getchar();

stdc.c(249) : Warning 534: Ignoring return value of function

’’_filbuf(struct _iobuf *)’’ (compare with line 275, file stdio.h)

stdio.h(275) : Info 830: Location cited in prior message

_

scanf("%d",&list->price);

stdc.c(257) : Info 725: Expected positive indentation from line 254

stdc.c(254) : Info 830: Location cited in prior message

_

menu();

stdc.c(265) : Warning 534: Ignoring return value of function

’’menu(void)’’ (compare with line 42)

stdc.c(42) : Info 830: Location cited in prior message

_

}

stdc.c(268) : Info 744: switch statement has no default

_

{

stdc.c(281) : Warning 578: Declaration of symbol ’’list’’ hides symbol

’’list’’ (line 21)

stdc.c(21) : Info 830: Location cited in prior message

_

menu();

stdc.c(303) : Warning 534: Ignoring return value of function

’’menu(void)’’ (compare with line 42)

stdc.c(42) : Info 830: Location cited in prior message

_

exit();

stdc.c(308) : Error 118: Too few arguments (0) for prototype

’’exit(int)’’

_

}

stdc.c(311) : Info 744: switch statement has no default

_

{

stdc.c(319) : Error 18: Symbol ’’exit(int)’’ redecla red (void/nonvoid,

arg. count) conflicts with line 261, file stdlib.h

stdlib.h(261) : Info 830: Location cited in prior message

_

{

stdc.c(319) : Warning 515: Symbol ’’exit(void)’’ has arg. count conflict

(0 vs. 1) with line 261, file stdlib.h

stdlib.h(261) : Info 830: Location cited in prior message

_

{

stdc.c(319) : Warning 532: Return mode of function ’’exit(void)’’

inconsistent with line 261, file stdlib.h

stdlib.h(261) : Info 830: Location cited in prior message

_

menu();

stdc.c(331) : Warning 534: Ignoring return value of function

’’menu(void)’’ (compare with line 42)

stdc.c(42) : Info 830: Location cited in prior message

_

return 0;

stdc.c(338) : Warning 527: Unreachable code at token ’’return’’

_

}

stdc.c(339) : Info 744: switch statement has no default

_

}

stdc.c(340) : Warning 533: function ’’exit(void)’’ should return a value

(see line 318)

stdc.c(318) : Info 830: Location cited in prior message


--- Global Wrap-up


Note 900: Successful completion, 91 messages produced

Tool returned code: 0


--

jay

And then top it off with a run through PC-lint from
http://www.gimpel.com/ (warnings like 525 are supressed, and line
numbers may differ slightly to those in your source):

PC-lint for C/C++ (NT) Vers. 8.00u, Copyright Gimpel Software
1985-2006

--- Module: stdc.c (C)
_
int exit(void);
stdc.c(10) : Error 18: Symbol ''exit(int)'' redeclared (void/nonvoid,
arg. count) conflicts with line 261, file stdlib.h
stdlib.h(261) : Info 830: Location cited in prior message
_
int exit(void);
stdc.c(10) : Warning 532: Return mode of function ''exit(int)''
inconsistent with line 261, file stdlib.h
stdlib.h(261) : Info 830: Location cited in prior message
_
menu();
stdc.c(33) : Warning 534: Ignoring return value of function
''menu(void)'' (compare with line 6)
stdc.c(6) : Info 830: Location cited in prior message
_
#... = (char)((''\n\n''))) : _flsbuf(((''\n\n'')),((&_iob[1])))) /*lint
-restore *
#... (''\n\n''),stdout)
putchar(''\n\n'');
stdc.c(51) : Info 742: Multiple character constant
_
#... _flsbuf(((''\n\n'')),((&_iob[1])))) /*lint -restore */
#... (''\n\n''),stdout)
putchar(''\n\n'');
stdc.c(51) : Info 742: Multiple character constant
_
insert();
stdc.c(66) : Warning 534: Ignoring return value of function
''insert(void)'' (compare with line 7)
stdc.c(7) : Info 830: Location cited in prior message
_
search();
stdc.c(71) : Warning 534: Ignoring return value of function
''search(void)'' (compare with line 8)
stdc.c(8) : Info 830: Location cited in prior message
_
show(list);
stdc.c(76) : Warning 534: Ignoring return value of function
''show(struct sells *)'' (compare with line 9)
stdc.c(9) : Info 830: Location cited in prior message
_
exit();
stdc.c(81) : Error 118: Too few arguments (0) for prototype
''exit(int)''
_
}
stdc.c(84) : Info 744: switch statement has no default
_
printf("%f\n",&m_out);
stdc.c(100) : Warning 559: Size of argument no. 2 inconsistent with
format
_
scanf("%s",&titlos);
stdc.c(104) : Warning 545: Suspicious use of &
stdc.c(104) : Warning 561: (arg. no. 2) indirect object inconsistent
with format
_
getchar();
stdc.c(105) : Warning 534: Ignoring return value of function
''_filbuf(struct _iobuf *)'' (compare with line 275, file stdio.h)
stdio.h(275) : Info 830: Location cited in prior message
_
scanf("%s",&tragoudisths);
stdc.c(109) : Warning 545: Suspicious use of &
stdc.c(109) : Warning 561: (arg. no. 2) indirect object inconsistent
with format
_
getchar();
stdc.c(110) : Warning 534: Ignoring return value of function
''_filbuf(struct _iobuf *)'' (compare with line 275, file stdio.h)
stdio.h(275) : Info 830: Location cited in prior message
_
getchar();
stdc.c(114) : Warning 534: Ignoring return value of function
''_filbuf(struct _iobuf *)'' (compare with line 275, file stdio.h)
stdio.h(275) : Info 830: Location cited in prior message
_
getchar();
stdc.c(120) : Warning 534: Ignoring return value of function
''_filbuf(struct _iobuf *)'' (compare with line 275, file stdio.h)
stdio.h(275) : Info 830: Location cited in prior message
_
getchar();
stdc.c(122) : Warning 534: Ignoring return value of function
''_filbuf(struct _iobuf *)'' (compare with line 275, file stdio.h)
stdio.h(275) : Info 830: Location cited in prior message
_
printf("%f",&m_out);
stdc.c(135) : Warning 559: Size of argument no. 2 inconsistent with
format
_
printf("%f",&m_out);
stdc.c(140) : Warning 559: Size of argument no. 2 inconsistent with
format
_
printf("Press \"1\" to return to menu or \"2\" to exit\n");
stdc.c(159) : Warning 539: Did not expect positive indentation from
line 154
stdc.c(154) : Info 830: Location cited in prior message
_
printf("Press \"1\" to return to menu or \"2\" to exit\n");
stdc.c(159) : Warning 539: Did not expect positive indentation from
line 142
stdc.c(142) : Info 830: Location cited in prior message
_
printf("Press \"1\" to return to menu or \"2\" to exit\n");
stdc.c(159) : Warning 539: Did not expect positive indentation from
line 137
stdc.c(137) : Info 830: Location cited in prior message
_
menu();
stdc.c(167) : Warning 534: Ignoring return value of function
''menu(void)'' (compare with line 42)
stdc.c(42) : Info 830: Location cited in prior message
_
exit();
stdc.c(172) : Error 118: Too few arguments (0) for prototype
''exit(int)''
_
}
stdc.c(175) : Info 744: switch statement has no default
_
gets(titlos);
stdc.c(191) : Warning 534: Ignoring return value of function
''gets(char *)'' (compare with line 324, file stdio.h)
stdio.h(324) : Info 830: Location cited in prior message
_
gets(titlos);
stdc.c(191) : Warning 421: Caution -- function ''gets(char *)'' is
considered dangerous
_
getchar();
stdc.c(192) : Warning 534: Ignoring return value of function
''_filbuf(struct _iobuf *)'' (compare with line 275, file stdio.h)
stdio.h(275) : Info 830: Location cited in prior message
_
menu();
stdc.c(204) : Warning 534: Ignoring return value of function
''menu(void)'' (compare with line 42)
stdc.c(42) : Info 830: Location cited in prior message
_
exit();
stdc.c(209) : Error 118: Too few arguments (0) for prototype
''exit(int)''
_
}
stdc.c(212) : Info 744: switch statement has no default
_
getchar();
stdc.c(231) : Warning 534: Ignoring return value of function
''_filbuf(struct _iobuf *)'' (compare with line 275, file stdio.h)
stdio.h(275) : Info 830: Location cited in prior message
_
gets(list->tittle);
stdc.c(235) : Warning 534: Ignoring return value of function
''gets(char *)'' (compare with line 324, file stdio.h)
stdio.h(324) : Info 830: Location cited in prior message
_
gets(list->tittle);
stdc.c(235) : Warning 421: Caution -- function ''gets(char *)'' is
considered dangerous
_
getchar();
stdc.c(236) : Warning 534: Ignoring return value of function
''_filbuf(struct _iobuf *)'' (compare with line 275, file stdio.h)
stdio.h(275) : Info 830: Location cited in prior message
_
getchar();
stdc.c(240) : Warning 534: Ignoring return value of function
''_filbuf(struct _iobuf *)'' (compare with line 275, file stdio.h)
stdio.h(275) : Info 830: Location cited in prior message
_
gets(list->singer);
stdc.c(244) : Warning 534: Ignoring return value of function
''gets(char *)'' (compare with line 324, file stdio.h)
stdio.h(324) : Info 830: Location cited in prior message
_
gets(list->singer);
stdc.c(244) : Warning 421: Caution -- function ''gets(char *)'' is
considered dangerous
_
getchar();
stdc.c(245) : Warning 534: Ignoring return value of function
''_filbuf(struct _iobuf *)'' (compare with line 275, file stdio.h)
stdio.h(275) : Info 830: Location cited in prior message
_
getchar();
stdc.c(249) : Warning 534: Ignoring return value of function
''_filbuf(struct _iobuf *)'' (compare with line 275, file stdio.h)
stdio.h(275) : Info 830: Location cited in prior message
_
scanf("%d",&list->price);
stdc.c(257) : Info 725: Expected positive indentation from line 254
stdc.c(254) : Info 830: Location cited in prior message
_
menu();
stdc.c(265) : Warning 534: Ignoring return value of function
''menu(void)'' (compare with line 42)
stdc.c(42) : Info 830: Location cited in prior message
_
}
stdc.c(268) : Info 744: switch statement has no default
_
{
stdc.c(281) : Warning 578: Declaration of symbol ''list'' hides symbol
''list'' (line 21)
stdc.c(21) : Info 830: Location cited in prior message
_
menu();
stdc.c(303) : Warning 534: Ignoring return value of function
''menu(void)'' (compare with line 42)
stdc.c(42) : Info 830: Location cited in prior message
_
exit();
stdc.c(308) : Error 118: Too few arguments (0) for prototype
''exit(int)''
_
}
stdc.c(311) : Info 744: switch statement has no default
_
{
stdc.c(319) : Error 18: Symbol ''exit(int)'' redeclared (void/nonvoid,
arg. count) conflicts with line 261, file stdlib.h
stdlib.h(261) : Info 830: Location cited in prior message
_
{
stdc.c(319) : Warning 515: Symbol ''exit(void)'' has arg. count conflict
(0 vs. 1) with line 261, file stdlib.h
stdlib.h(261) : Info 830: Location cited in prior message
_
{
stdc.c(319) : Warning 532: Return mode of function ''exit(void)''
inconsistent with line 261, file stdlib.h
stdlib.h(261) : Info 830: Location cited in prior message
_
menu();
stdc.c(331) : Warning 534: Ignoring return value of function
''menu(void)'' (compare with line 42)
stdc.c(42) : Info 830: Location cited in prior message
_
return 0;
stdc.c(338) : Warning 527: Unreachable code at token ''return''
_
}
stdc.c(339) : Info 744: switch statement has no default
_
}
stdc.c(340) : Warning 533: function ''exit(void)'' should return a value
(see line 318)
stdc.c(318) : Info 830: Location cited in prior message

--- Global Wrap-up

Note 900: Successful completion, 91 messages produced
Tool returned code: 0

--
jay


这篇关于在C中帮助这个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆