这是两个结构,客户端&雇员获得不兼容的类型中分配
struct client
{
char clID[10];
char cname[50];
char caddress[99];
char cemail[99];
char cfees[6];
char ceID[10];
char cename[50];
}typedef client;
struct employee
{
char empID[10];
char ename[50];
double erate;
double ehours;
double esalary;
int clientCount;
}typedef employee;
这是在其中一个客户输入信息之后,用户被提示以分配由ID雇员的搜索情况下,然后将雇员存储在ID名称被添加在客户机结构
case 1: getClient(clCount, pcli);
printf("Enter an employee to assign to this client: ");
scanf("%9s", searchID);
searchEmp(searchID, pemp, empCount);
foundAt = searchEmp(searchID, pemp, empCount);
if(foundAt >= 0)
if(pemp[foundAt].clientCount < 5)
{
strcpy(pcli[clCount].ceID, searchID);
这一行是其中误差从 PCLI [clCount] .cename = PEMP [foundAt] .ename来cename;
pcli[clCount].cename = pemp[foundAt].ename;
pemp[foundAt].clientCount++;
}
else
{
printf("Max clients reached for this employee!");
}
else
printf("%s is not found anywhere\n", searchID);
clCount++;
break;
搜索方法:
int searchEmp(char* searchID, employee* pemp, int empCount)
{
int i = 0;
for(i = 0; i < empCount; i++)
{
if(strcmp(searchID,(pemp + i)->empID)==0)
{
return i;
}
}
return -1;
}//end searchClient
尝试熨出symtax错误 - 例如'struct ... typedef client' – 2014-12-06 07:49:26
你想复制字符串吗?那样的话,为什么不用strncpy? – lpapp 2014-12-06 07:51:46
是的,我需要位于pemp [foundAt] .ename中的字符串被复制到pcli [clCount] .cename – Takume 2014-12-06 07:53:29