c语言关于结构定义和条件编译 VC++6.0 为什么把结构声明放到函数声明后面和主函数里都编译错误
把#ifdef改为#ifdefine也编译错误#include<stdio.h>#defineNAME_LEN25#ifdefNAME_LENstructpart{int...
把#ifdef改为#if define也编译错误
#include<stdio.h>
#define NAME_LEN 25
#ifdef NAME_LEN
struct part
{
int number;
char name[NAME_LEN+1];
int on_hand;
};
#endif
void print_struct(struct part p);
void main()
{
struct part part1 = { 528, "Disk drive", 10};
print_struct(part1);
}
void print_struct(struct part p)
{
printf("Part number: %d\n",p.number);
printf("Part name: %s\n",p.name);
printf("Quantity on_hand: %d\n",p.on_hand);
} 展开
#include<stdio.h>
#define NAME_LEN 25
#ifdef NAME_LEN
struct part
{
int number;
char name[NAME_LEN+1];
int on_hand;
};
#endif
void print_struct(struct part p);
void main()
{
struct part part1 = { 528, "Disk drive", 10};
print_struct(part1);
}
void print_struct(struct part p)
{
printf("Part number: %d\n",p.number);
printf("Part name: %s\n",p.name);
printf("Quantity on_hand: %d\n",p.on_hand);
} 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询