----
1>Deleting intermediate and output files for project 'ex6', configuration 'Debug|Win32'
1>Compiling...
1>ex6.c
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(19) : error C2143: syntax error : missing ';' before '{'
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(81) : error C2143: syntax error : missing ';' before 'type'
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(83) : error C2065: 'j' : undeclared identifier
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(83) : error C2065: 'count' : undeclared identifier
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(83) : error C2065: 'i' : undeclared identifier
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(84) : error C2065: 'curr' : undeclared identifier
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(84) : error C2224: left of '.candidate' must have struct/union type
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(84) : error C2039: 'candidate' : is not a member of '_iobuf'
1> c:\program files\microsoft visual studio 8\vc\include\stdio.h(59) : see declaration of '_iobuf'
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(85) : warning C4098: 'report' : 'void' function returning a value
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(86) : error C2224: left of '.type' must have struct/union type
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(86) : error C2039: 'type' : is not a member of '_iobuf'
1> c:\program files\microsoft visual studio 8\vc\include\stdio.h(59) : see declaration of '_iobuf'
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(87) : warning C4098: 'report' : 'void' function returning a value
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(88) : error C2224: left of '.type' must have struct/union type
1>c:\documents and settings\lun\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(88) : error C2039: 'type' : is not a member of '_iobuf'
1> c:\program files\microsoft visual studio 8\vc\include\stdio.h(59) : see declaration of '_iobuf'
1>c:\documents and settings\\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(90) : warning C4098: 'report' : 'void' function returning a value
1>c:\documents and settings\my documents\visual studio 2005\projects\ex6\ex6\ex6.c(92) : warning C4098: 'report' : 'void' function returning a value
1>Build log was saved at "file://c:\Documents and Settings\lun\My Documents\Visual Studio 2005\Projects\ex6\ex6\Debug\BuildLog.htm"
1>ex6 - 12 error(s), 4 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Code:#include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct vote { char name [30]; int id,type,candidate; } vote; void report(FILE* college[3], FILE* arr[10], char* canceled){ // Fuction returns the minimal id int getMin(int eof[],vote [],int *); // Function checks a vote record correct int votecheck(vote ,vote [],int i); // Function reads the next record from "college" file int readFrom(FILE *,vote [],int); void report(FILE *college[3], FILE *arr[10], char* canceled){ FILE *cancel; vote currtable[3], // array for three current "college" records votable[3], // array for checking the records with the same "id" current; // struct for the current "college" record int i,j,idmin,index,flag,eof[3]; if(!(cancel=fopen(canceled,"w"))) exit(1); for(i=0;i<3;i++) eof[i]= readFrom(college[i],currtable,i); // main loop while(eof[0]!=EOF||eof[1]!=EOF||eof[2]!=EOF){ idmin=getMin(eof,currtable,&index); for(i=flag=0;i<3;i++) if(i!=index && eof[i]!=EOF && currtable[i].id==idmin) flag=3; if(flag){ fprintf(cancel,"%s%d%d\n",currtable[index].name,idmin,flag); for(i=0;i<3;i++) while(eof[i]!=EOF && currtable[i].id==idmin) eof[i]=readFrom(college[i],currtable,i); continue; } //Filling struct table for the minimal id votable[0]=currtable[index]; i=1; while(eof[index]!=EOF && i<3){ eof[index]=fscanf(college[index],"%30[^\n]%9d%1d%1d%*c", current.name,¤t.id,¤t.type,¤t.candidate); if(current.id!=idmin){ for(j=0;j<i;j++) fprintf(arr[votable[j].candidate],"%9d%d%d\n", idmin,index,votable[j].type); currtable[index]=current; break; } else{ flag=votecheck(current,votable,i); if(flag){ fprintf(cancel,"%s%d%d\n",currtable[index].name,idmin,flag); while(eof[index]!=EOF && currtable[index].id==idmin) eof[index]=readFrom(college[index],currtable,index); break; } else votable[i++]=current; }//else }//while if(i<3) continue; if(eof[index]!=EOF) eof[index]=fscanf(college[index],"%30[^\n]%9d%1d%1d%*c", current.name,¤t.id,¤t.type,¤t.candidate); if(eof[index]==EOF ||current.id!=idmin ){ for(j=0;j<i;j++) fprintf(arr[votable[j].candidate],"%9d%d%d\n", idmin,index,votable[j].type); currtable[index]=current; } else{ fprintf(cancel,"%s%d%d\n",votable[0].name,idmin,2); while(eof[index]!=EOF && currtable[index].id==idmin) eof[index]=readFrom(college[index],currtable,index); } }// main loop - while fclose(cancel); }// report int votecheck(vote curr,vote arr[],int i){ int j,count; for(j=count=0;j<i;j++){ if(curr.candidate==arr[j].candidate) return 1; if(curr.type==1 && arr[j].type==1) return 2; if(curr.type==2 && arr[j].type==2) count++; if(count>1) return 2; } return 0; } int readFrom(FILE *coll,vote table[],int i){ return fscanf(coll,"%30[^\n]%9d%1d%1d%*c",table[i].name, &table[i].id,&table[i].type,&table[i].candidate); } int getMin(int eof[],vote table[],int *index){ int i,idmin; for(i=0,idmin=999999999;i<3;i++) if(eof[i]!=EOF && table[i].id<idmin){ idmin=table[i].id; *index=i; } return idmin; }