Hello everyone, I might be need your help in a thing that has been bothering me.
I have a function called map() that creates a file called 'merdas.txt' and writes to it.
After that, I call a function called map2() that collects the information inside 'merdas.txt' and separates it in a few files.
Now, this is working, thing is, it only works this way.
I compile the executable 1st time :
'merdas.txt' is created.
I compile the executable 2nd time :
The few files separately are created.
This is my function that separates 'merdas.txt' in a few :
Code:
void map2(){
FILE* fpp;
FILE* fppp;
int i=0;
int chave;
int linhas=0;
size_t len;
char* fich;
char valor[MAXSTRING];
fpp = fopen("merdas.txt","r");
if (fpp == NULL) { printf("Este ficheiro ainda não existe \n");}
else {printf("Existe o ficheiro \n");}
while(fscanf(fpp,"%d %s",&chave,&valor)!=-1){
//printf("chave:%d\nvalor:%s\n",chave,valor);
const char *str = coiso(chave);
printf("Vou começar a imprimir os nomes \n");
printf("str: %s\n",str);
fppp=fopen(str,"a+");
//printf("criou o ficheiro\n");
fprintf(fppp,"%s\n",valor);
ficheiros[chave]=1;
}
fclose(fpp);
}
It tells me the file exists so I have no idea why it ain't creating the few files.
Thanks.