Hi guys o/ !
I'm trying to make a program that write in text file some datas.
Then, i wrote a header that have all functions I need to write in this file.
thas is my header:
#ifndef _SNAPSHOT_H
#define _SNAPSHOT_H
#define LAST_PRICE 0;
#define BEST_ASK 1;
#define BEST_BID 2;
#define HIGH 3;
#define LOW 4;
#define OPEN 5;
#define CLOSE 6;
#define TRADES 7;
int snapwrite(char *_symbol, int _typeval, char *_val) {
int sw;
//Descritor do arquivo
FILE *sfl;
char *sflparam;
sflparam = malloc(strlen(_symbol)+5);
switch (_typeval) {
case 0:
//Escreve
strcpy(sflparam,_symbol);
strcat(sflparam,".lst");
sfl= fopen(sflparam,"w");
sw = fprintf(sfl,"LAST \t : %s\n", _val);
break;
case 1:
strcpy(sflparam,_symbol);
strcat(sflparam,".bsk");
sfl= fopen(sflparam,"w");
sw = fprintf(sfl,"BEST_ASK \t : %s\n", _val);
break;
case 2:
strcpy(sflparam,_symbol);
strcat(sflparam,".bsd");
sfl= fopen(sflparam,"w");
sw = fprintf(sfl,"BEST_BID \t : %s\n", _val);
break;
default:
sw = -1;
break;
}
//Fecha descritor salvando alterações
fclose(sfl);
return sw;
}
#endif /* _SNAPSHOT_H */
And then, I use in my source file :
snapwrite(file, LAST_PRICE, "text");
But, when I put LAST_PRICE, does not works, but if I put 0, does work very well.
I wanna to use the define tags, because this header will use in another programs.
What i'm doing wrong?
Thanks for any help;