I've been breaking my head with this problem because if I occupy Codeblocks with wingw it does not throw me any problems
char *getArchivoSalida(int num)
{
char nombre[1024] = "";
sprintf(nombre, "Imagenx%d.ppm", num);
ofstream fs(nombre);
fs.close();
return nombre;
}
int binario(char *nombre, int n)
{
FILE *entrada, *salida;
unsigned char red, green, blue;
char *archivoSalida = "";
char formato[3];
int height, width, depth;
int widthCont = 1;
entrada = fopen(nombre, "rb");
if (entrada == NULL)
{
printf("NO SE PUDO ABRIR\n");
system("pause");
return -1;
}
archivoSalida = getArchivoSalida(n);
salida = fopen(archivoSalida ,"w+");
fscanf(entrada, "%s", formato);
/Continua abajo/
}
The problem is that in the line of salida = fopen(archivoSalida, "w+")
when you see the error in the compiler it appears that the vaiable% FILE
output contains a value null thing that should receive the name of the file.
I do not know how it gets lost, I tried to put it as a constant variable but nothing
The last straw is that if I enter
salida = fopen("Imagenx1.ppm", "w+");
works perfectly ....
what's going on, is it a vc ++ problem?
greetings
Edition: