Can someone explain me the steps to follow to export the data originated in a dialog based visual c++ (version 6.0) program to a CSV file?
I've tried somthing like this:
Expand|Select|Wrap|Line Numbers
- void CSizeDistributionDlg::OnSave()
- {
- // TODO: Code für die Behandlungsroutine der Steuerelement-Benachrichtigung hier einfügen
- const char *filename = "C:\Documents and Settings\X\Desktop\trycsv.csv";
- FILE *Archi;
- Archi = fopen(filename,"w");
- if (Archi==0)
- fprintf(stderr, "Fallo abriendo... %s para escribir\n",filename);
- fprintf(Archi,"Hola mundo\n");
- fprintf(Archi,"Hola,Mundo\n");//etc...
- fclose(Archi);
- }
- void CSizeDistributionDlg::OnOpen()
- {
- // TODO: Code für die Behandlungsroutine der Steuerelement-Benachrichtigung hier einfügen
- char linea[100], cadena[100];
- const char *filename = "C:\Documents and Settings\X\Desktop\trycsv.csv";
- FILE *Archi;
- Archi = fopen(filename,"r");
- if (Archi==0)
- fprintf(stderr,"Fallo al abrir %s \n",filename);
- for(int j=0;;j++){//total lineas
- if (feof(Archi)) break;
- for (int i=0;i<100;i++) {//caracteres
- linea[i]=fgetc(Archi);
- if (linea[i]=='\n') break;
- if (feof(Archi)) break;
- }
- linea[i] = '\n'; //fin d datos de las celdas
- strcpy(cadena, linea); //ultima cadena
- }
- fclose(Archi);
- }
but it gives me errors when running it (Debug assertion failed)
Should I include something else, like headers or classes...?? I'm quite new in programming and I have not a global vision of this....
The reason I need to export to CSV is to open then with excel...
Thank you in advance!!