麻烦各位高手指点下以下程序哪出错了struct book{uchar name[10];uchar tell[10]; }tel[]={ {"abcd","3244"},{"dd","123"},{"sdf","13456"},{"uiy","836"},{"jk","967"},};void delete_string(int n)//删除第N条记录{int j;int s=sizeof(tel)/si

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 14:53:57
麻烦各位高手指点下以下程序哪出错了structbook{ucharname[10];uchartell[10];}tel[]={{"abcd","3244"},{"dd","123"},{"sdf",

麻烦各位高手指点下以下程序哪出错了struct book{uchar name[10];uchar tell[10]; }tel[]={ {"abcd","3244"},{"dd","123"},{"sdf","13456"},{"uiy","836"},{"jk","967"},};void delete_string(int n)//删除第N条记录{int j;int s=sizeof(tel)/si
麻烦各位高手指点下以下程序哪出错了
struct book
{
uchar name[10];
uchar tell[10];
}
tel[]=
{
{"abcd","3244"},
{"dd","123"},
{"sdf","13456"},
{"uiy","836"},
{"jk","967"},
};
void delete_string(int n)//删除第N条记录
{
int j;
int s=sizeof(tel)/sizeof(struct book);
for(j=n;j

麻烦各位高手指点下以下程序哪出错了struct book{uchar name[10];uchar tell[10]; }tel[]={ {"abcd","3244"},{"dd","123"},{"sdf","13456"},{"uiy","836"},{"jk","967"},};void delete_string(int n)//删除第N条记录{int j;int s=sizeof(tel)/si
tel[s-1].name和tel[s-1].tell是字符数组类型,不能直接赋值,可以用串函数中的strcpy,不过要在程序开头加上#include
再将tel[s-1].name='\0';
tel[s-1].tell='\0';
这两条语句改为
strcpy(tel[s-1].name,"\0"); //注意是双引号
strcpy( tel[s-1].tell,"\0");
还有一种简单方法可以将'\0’赋给数组第一个元素.
是需要将 tel[s-1].name='\0';
tel[s-1].tell='\0';
这两条语句改为
tel[s-1].name[0]='\0'; //注意是单引号
tel[s-1].tell[0]='\0';