Purtroppo non ho idea di come compilare il codice per MAC.
Se qualcuno ha un MAC e si intende di C++ non dovrebbe avere alcuna difficoltà a compilare il sorgente.
Colgo l'occasione per postare il sorgente aggiornato (si fa per dire) con la modifica che evita il troncamento all'80-ma colonna.
Ciao a tutti.codice:#include <stdio.h> #include <string.h> bool isFileExist(char* nomefile) { FILE *stream; if ((stream=fopen(nomefile,"r"))!=NULL) { return true; } else { return false; } } void num2str(int num, char* str) { if (num==0) strcpy(str,"0"); else strcpy(str,""); while (num) { switch (num % 10) { case 0: strcat(str,"0"); break; case 1: strcat(str,"1"); break; case 2: strcat(str,"2"); break; case 3: strcat(str,"3"); break; case 4: strcat(str,"4"); break; case 5: strcat(str,"5"); break; case 6: strcat(str,"6"); break; case 7: strcat(str,"7"); break; case 8: strcat(str,"8"); break; case 9: strcat(str,"9"); break; } num=(int) (num/10); } _strrev(str); } int main(int argc, char* argv[]) { /* sendmail path file Crea dei file al posto delle email. Path è il percorso assoluto della cartella dove mettere i file. Deve esistere. Se non specificato path="C:\". File è il nome del file in cui inviare l'output. I file vengono automaticamente numerati. Se non specificato file="email". p.e. sendmail c:\mails\ mail sendmail c:\mails\ */ // Inizializzo le variabili FILE *stream; char buffer[81]; char nomefile[41]; char stringa[10]; int i=0,ch='a',j=0; bool leggi=true; // Inizializzo gli argomenti switch (argc) { case 1: argv[1]="c:\\"; case 2: argv[2]="email"; } //Preparo il nomefile di output do { strcpy(nomefile,""); strcat(nomefile,argv[1]); strcat(nomefile,argv[2]); num2str(j,stringa); strcat(nomefile,stringa); strcat(nomefile,".eml"); j++; } while (isFileExist(nomefile)); //Apro il file di output if ((stream=fopen(nomefile,"w"))!=NULL) { while (!(((buffer[0]=='.')&&(buffer[1]=='\n'))||(ch == EOF))) { // Prende massimo 80 byte alla volta for(i=0;(i<79)&&((ch = getchar()) != EOF)&&(ch != '\n');i++) { buffer[i] = (char) ch; } if (ch=='\n') buffer[i++] = '\n'; // <= termine di riga // Mette la riga nel file. fwrite(buffer,sizeof(char),i,stream); } fclose(stream); } else { return 1; } return 0; }

) con la modifica che evita il troncamento all'80-ma colonna.
Rispondi quotando