当前位置: 技术问答>linux和unix
用gcc编译linux下c++程序 报: stray '\343’ in program 这样的错误,是什么意思?
来源: 互联网 发布时间:2015-09-08
本文导语: 源代码是从网上拷的。 //mywrite.c //www.beeship.com //pianopan@beeship.com //2002-2-4 #include #include #include #include #include #define ITEM_NAME_LENGTH 9 #define PERMS 0666 #define FILE_NAME "tempfile" #define ITEM_COUNT 10 struct data_struct { i...
源代码是从网上拷的。
//mywrite.c
//www.beeship.com
//pianopan@beeship.com
//2002-2-4
#include
#include
#include
#include
#include
#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);
}
//mywrite.c
//www.beeship.com
//pianopan@beeship.com
//2002-2-4
#include
#include
#include
#include
#include
#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);
}
|
检查一下代码报错的地方
那儿出现了非法字符
(ASCII 227)
那儿出现了非法字符
(ASCII 227)