我的DevC++编译带有自定义头文件的程序时出错。

这是.h文件的代码:/*readline.h*/#ifndefREADLINE_H#defineREADLINE_Hintread_line(charstr[],intn... 这是.h文件的代码:

/* readline.h */

#ifndef READLINE_H
#define READLINE_H

int read_line(char str[], int n);

#endif

这是主程序:
#include <stdio.h>
#include <stdlib.h>
#include "readline.h"

#define NAME_LEN 25

struct part {
int number;
char name[NAME_LEN+1];
int on_hand;
struct part *next;
};

struct part *inventory = NULL; /* points to first part */

struct part *find_part(int number);
void insert(void);
void search(void);
void update(void);
void print(void);

int main(void)
{
char code;

for (;;) {
printf("Enter operation code: ");
scanf(" %c", &code);
while (getchar() != '\n') /* skips to end of line */
;
switch (code) {
case 'i': insert();
break;
case 's': search();
break;
case 'u': update();
break;
case 'p': print();
break;
case 'q': return 0;
default: printf("Illegal code\n");
}
printf("\n");
}
}

struct part *find_part(int number)
{
struct part *p;

for (p = inventory;
p != NULL && number > p->number;
p = p->next)
;
if (p != NULL && number == p->number)
return p;
return NULL;
}

void insert(void)
{
struct part *cur, *prev, *new_node;

new_node = malloc(sizeof(struct part));
if (new_node == NULL) {
printf("Database is full; can't add more parts.\n");
return;
}

printf("Enter part number: ");
scanf("%d", &new_node->number);

for (cur = inventory, prev = NULL;
cur != NULL && new_node->number > cur->number;
prev = cur, cur = cur->next)
;
if (cur != NULL && new_node->number == cur->number) {
printf("Part already exists.\n");
free(new_node);
return;
}

printf("Enter part name: ");
read_line(new_node->name, NAME_LEN);
printf("Enter quantity on hand: ");
scanf("%d", &new_node->on_hand);

new_node->next = cur;
if (prev == NULL)
inventory = new_node;
else
prev->next = new_node;
}

void search(void)
{
int number;
struct part *p;

printf("Enter part number: ");
scanf("%d", &number);
p = find_part(number);
if (p != NULL) {
printf("Part name: %s\n", p->name);
printf("Quantity on hand: %d\n", p->on_hand);
} else
printf("Part not found.\n");
}

void update(void)
{
int number, change;
struct part *p;

printf("Enter part number: ");
scanf("%d", &number);
p = find_part(number);
if (p != NULL) {
printf("Enter change in quantity on hand: ");
scanf("%d", &change);
p->on_hand += change;
} else
printf("Part not found.\n");
}

void print(void)
{
struct part *p;

printf("Part Number Part Name "
"Quantity on Hand\n");
for (p = inventory; p != NULL; p = p->next)
printf("%7d %-25s%11d\n", p->number, p->name,
p->on_hand);
}
展开
 我来答
  • 你的回答被采纳后将获得:
  • 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
匿名用户
2015-07-31
展开全部
uservo user=(uservo)voinfo;
String username=user.getUsername();
String password=user.getPassword();
System.out.println("your username is "+username);
System.out.println("your password is "+password);
List list = new ArrayList();
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式