用gcc编译linux下c++程序 报: stray '\343’ in program 这样的错误,是什么意思?

collecte 2005-02-17 11:42:48
源代码是从网上拷的。

//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);
}
...全文
1406 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zeusnchen 2005-02-17
  • 打赏
  • 举报
回复
检查一下代码报错的地方
那儿出现了非法字符
(ASCII 227)

23,214

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧