debugging - (solved) c++ fix syntax debug with *lec=fopen(); -


i working on c++ code friend know better do, , code has bug, i'd fix this, since couldn't figure out how...

edit compiler stops @ line 59 where: file *ecr("result.txt","wt"); written.

there many other things fix, fixed until 49 (59 ;) ) blocked again...

thanks!

edit (again, sorry) message:

c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp||in function 'int main()':| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|59|error: expression list treated compound expression in initializer [-fpermissive]| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|59|error: cannot convert 'const char*' 'file* {aka _iobuf*}' in initialization| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|82|error: expected initializer before '<' token| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|82|error: expected ';' before '<' token| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|82|error: expected primary-expression before '<' token| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|84|error: expected ')' before ']' token| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|84|error: expected ')' before ']' token| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|84|error: expected primary-expression before ']' token| c:\users\ad\desktop\python\josh\josh\color\3d\solution_to_array.cpp|84|error: expected ';' before ']' token| ||=== build finished: 9 errors, 0 warnings (0 minutes, 0 seconds) ===| 

if figure how fix this, great!

code:

#include <iostream> #include <fstream> #include <sstream> #include <string> #include <stdio.h> #include <string.h> using namespace std;   int main() {  int col = 0; int lin = 0;  cout << endl << "columns?" << endl; cin  >> col; cout << "lines?" << endl; cin  >> lin;  int cell = lin*col;  cout << cell << " cells" << endl;  //1- reading file priority.csv char coul[col][lin]; (int i=0; i<col; i++) coul[i][0]='\0';  file *lec=fopen("priority.csv","rt");  if (lec == null) {         printf("error");         return(0); }  char ligne[120]; int n;  (int i=0; i<col; i++) {   char nom[8];   fgets(ligne,15,lec);   sscanf(ligne,"%d,%s",&n,nom);   if (n == i) strcpy(coul[i], nom);    else {printf("error");   break;   } }  fclose(lec);  //2- reading file solution.txt , writing result. lec=fopen("solution.txt","rt"); // fixed here  if (lec == null) {printf("error");     return(0);     }  file *ecr=fopen("result.txt","wt"); //stops here (int i=1; i<cell; i++) {   char c[4][8];  // 4 color names   float v[4]; // 4 values   fgets(ligne,119,lec);   sscanf(ligne,"%d,%s,%f,%s,%f,%s,%f,%s,%f",               &n, c[0], &v[0], c[1], &v[1], c[2], &v[2], c[3], &v[3]);   if (n == i)   {     if (strlen(c[0]) == 0)  // la ligne est vide     {       fprintf(ecr,"%d ",i);       (int i=0; i<col; i++) fprintf(ecr,"0 ");       fprintf(ecr,"\n");     }     else     {       fprintf(ecr,"%d ",i);       int r[4]; // search rang of c[ordre]       (int ordre=0; ordre<4; ordre++)       {         (int ir=0, ir<col; ir++)         {           if (strcmp(c(ordre], coul[ir]) == 0) r[ordre]=ir;         }       }       (int ir=0; ir<r[0]; ir++) fprintf(ecr,"0 ");       fprintf(ecr,"%d ",v[0]);       (int ir=r[0]+1; ir<r[1]; ir++) fprintf(ecr,"0 ");       fprintf(ecr,"%d ",v[1]);       (int ir=r[1]+1; ir<r[2]; ir++) fprintf(ecr,"0 ");       fprintf(ecr,"%d ",v[2]);       (int ir=r[2]+1; ir<r[3]; ir++) fprintf(ecr,"0 ");       fprintf(ecr,"%d ",v[3]);       (int ir=r[3]+1; ir<57; ir++) fprintf(ecr,"0 ");       fprintf(ecr,"\n");     }   }   else {printf("error"); break;} } fclose (ecr); fclose(lec); } 

lec seems declared twice, second call should

lec=fopen("solution.txt","rt"); 

since have file* lec above


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -