Esta probando, ya que hace poco aprendí a dominar el batch bastante bien (te debes estar riendo), modificar, entender un poco el lenguaje C/C++ y me resulto excelente, cada paso que daba me daban mas ganas de aprenderlo, una especie de retroalimentacion positiva, y bueno voy por lo basico ahora, editar un "source" que tenia por alli de ejemplo y la verdad que me quede en:
char header[300] = ("\nCodigo creado por %d\n", creador);
no logro entender que es lo que hice mal que cuando lo compilo con g++, da error, si me dicen que es lo que hice mal me dan una gran ayuda que espero que me ayude en el futuro
Tengo entendido que d es para numero pero es solo para ejemplo
/*********************************************
* Batch DOS To C Source Code Converter v.1.1 *
* Coded by Samar Dhwoj Acharya aka $yph3r$am *
* Website => http://sampctricks.blogspot.com *
* E-mail meh at samar_acharya[at]hotmail.com *
* Contact meh at +9779841150346 (NTC <a href="http://cityadspix.com/tsclick-MIQCWPUV-GECAQBFF?url=http%3A%2F%2Fwww.sotmarket.ru%2Fproduct%2Fsandisk-microsdxc-64gb-class-10-ultra-sd-adapter.html&sa=mh&sa1=&sa2=&sa3=&sa4=&sa5=&bt=20&pt=9<=2&tl=3&im=ODI1LTAtMTQxOTM3ODQyMC0xNzQ0OTE1Ng%3D%3D&fid=NDQ1NzU2Nzc1&prdct=0a3e083f0a3b0a3d0a&kw=mobile)%20*%0A*%20I" target="_blank" alt="Mobile Ultra microSDXC UHS-I 64GB" title="Mobile Ultra microSDXC UHS-I 64GB" style="">mobile) *
* I</a> know to code: PHP, PERL, C, JAVA, PYTHON, ASM *
*********************************************/
/*
Some Notes:
-The program was created in real hurry in between end term exams
-So the program lacks all buffer overflow protections and optimization form
-The code can be modified but please don't change the credits for the file
-If you come up with better idea of implementing it in C, please contact me
-If you feel program is complete crap, do comment me personally or here
-If you loved my coding, I feel really glad for that.
-If you need to understand the coding(in fact, its just easy), contact me..
- Visit my site http://www.sampctricks.blogspot.com and my group site http://www.nepsecvulns.blogspot.com
*/
//include header files...
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int main(){
int creador;
FILE *fp;
char filename[30]; //filename for source code
// starting header of outputted file
char header[300] = ("\nCodigo creado por %d\n", creador);
//all the includes in output file
char incs[200] = "#include <stdio.h>\n#include <conio.h>\n#include <stdlib.h>\n#include <windows.h>\nint WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,\nPSTR szCmdLine, int iCmdShow)\n{\n";
//end part of output file
char end[50] = "\treturn 0;\n}";
//for command
char cmd[150];
printf("\t+----------------------------+\n");
printf("\t|BATCH TO C SOURCE CONVERTER |\n");
printf("\t|CODED BY SAMARDHWOJ ACHARYA |\n");
printf("\t+----------------------------+\n");
printf("Introduce el nombre del creador ");
scanf("%d", &creador);
printf("\nEnter the filename(with .c extension): ");
scanf("%s",filename);
fp = fopen(filename,"w");
if (fp==NULL)
{
printf("Some error occurred while opening file");
getch();
exit(1);
}
else
{
fprintf(fp,"%s%s",header,incs);
printf("\nNow start entering DOS commands: \n");
printf("When finished, type 'end' for the end of commands\n");
printf("\nStart:\n\n");
gets(cmd);
while (1)
{
gets(cmd);
if (!strcmp(cmd,"end"))
{
break; //if end is typed, get out of loop
}
fprintf(fp,"\tsystem(\"%s\");\n",cmd);
}
fprintf(fp,"\tprintf(\"\\n\");");
fprintf(fp,"\n%s",end);
printf("\n\nFile successfully created");
printf("\nNow compile it with any C compiler");
printf("\nThanks for using this little app");
fclose(fp);
}
getch();
}
EDITO:
CODIGO SOLUCIONADO, No a la perfección pero resuelto, gracias mod y a Yoel que ya me pongo a implementar tu código.
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int main()
{
FILE *fp;
char filename[30]; //filename for source code
// starting header of outputted file
char header[300] = "/*\nBatch DOS command To C source Converter\nBy sam207 (samar_acharya[at]hotmail.com)\nhttp://www.sampctricks.blogspot.com\nhttp://nepali.netau.net\n*/\n";
//all the includes in output file
char incs[200] = "#include <stdio.h>\n#include <conio.h>\n#include <stdlib.h>\n#include <windows.h>\nint WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,\nPSTR szCmdLine, int iCmdShow)\n{\n";
//end part of output file
char end[50] = "\treturn 0;\n}";
//for command
char cmd[150];
//para el resto, la clave
char cmb[350];
printf("\t+----------------------------+\n");
printf("\t|BATCH TO C SOURCE CONVERTER |\n");
printf("\t|CODED BY SAMARDHWOJ ACHARYA |\n");
printf("\t+----------------------------+\n");
printf("\nEnter the filename(with .c extension): ");
scanf("%s",filename);
printf("\nContraseña: ");
scanf("%s",cmb);
fp = fopen(filename,"w");
if (fp==NULL)
{
printf("Some error occurred while opening file");
getch();
exit(1);
}
else
{
fprintf(fp,"%s%s",header,incs);
fprintf(fp,"char clave[6];\n");
fprintf(fp,"printf(\"escriba su clave: \");\n");
fprintf(fp,"scanf(\"%%s\",clave);\n");
fprintf(fp,"if(strcmp(clave,\"%s\")==0)\n",cmb);
fprintf(fp,"{\n");
printf("\nNow start entering DOS commands: \n");
printf("When finished, type 'end' for the end of commands\n");
printf("\nStart:\n\n");
gets(cmd);
while (1)
{
gets(cmd);
if (!strcmp(cmd,"end"))
{
break; //if end is typed, get out of loop
}
fprintf(fp,"\tsystem(\"%s\");\n",cmd);
}
fprintf(fp,"\tprintf(\"\\n\");\n");
fprintf(fp,"\t}\nelse\n{\n");
fprintf(fp,"\tprintf(\"Clave no valida\");\n}\n");
fprintf(fp,"\n%s",end);
printf("\n\nFile successfully created");
printf("\nNow compile it with any C compiler");
printf("\nThanks for using this little app");
fclose(fp);
}
getch();
}