菜鸟求助,大虾们帮帮忙啊~~!
一个联合的试例程序,使用TC3.0编译通不过,不知道哪里有问题,希望各位大虾们指点下,谢谢了~!#include<stdio.h>
#include<stdlib.h>
union pw{
short int i;
char ch[2];
};
int putw(short int num,FILE *fp);
int main(void)
{
FILE *fp;
fp=fopen("test.tmp","wb+");
if(fp==NULL){
printf("Cannot open file.\n");
exit(1);
}
putw(1025,fp);
fclose(fp);
return 0;
}
int putw(short int num,FILE *fp)
{
union pw word;
word.i=num;
putc(word.ch[0],fp);
return putc(word.ch[1],fp);
}