用gcc编译linux下c++程序 报: stray '\343’ in program 这样的错误,是什么意思?
源代码是从网上拷的。
//mywrite.c
//www.beeship.com
//pianopan@beeship.com
//2002-2-4
#include<sys/types.h>
#include<sys/stat.h>
#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#define ITEM_NAME_LENGTH 9
#define PERMS 0666
#define FILE_NAME "tempfile"
#define ITEM_COUNT 10
struct data_struct
{
int data_id;
char item_name[ITEM_NAME_LENGTH +1];
};
typedef struct data_struct RECORD;
char *item_name[]={
"BEE","CAT","DOG",
"PIG","MONKEY","DONKEY",
"BIRD","RABBIT","HORSE",
"SHEEP"};
main()
{
int i;
int file_id;
RECORD record;
if((file_id=open(FILE_NAME,O_WRONLY | O_TRUNC|O_CREAT,PERMS))==-1)
{
perror("open");
exit(1);
}
printf("Open the files.....\n");
printf("The file was opened!\n");
/************************
write the date
*************************/
for(i=ITEM_COUNT -1;i>=0;i--)
{
record.data_id=i;
strcpy(record.item_name,item_name[i]);
printf("ID=%d :WRITE \"%s\"\n",i,item_name[i]);
lseek(file_id,(long)i*sizeof(RECORD),SEEK_SET);
write(file_id,(char*)&record,sizeof(RECORD));
}
printf("The command was completed!\n");
lseek(file_id,0L,SEEK_END);
close(file_id);
exit(0);
}