Hello everybody, i'm a computing student and i'm working in making a php compiler.
I have to make something like a preprocess to treat the #include sentences contained in the php scripts. I'm working with LEX/YACC and now i'm trying to make a function that can copy the code from a source file to another.
Doing this, if the source file is large, i obtain a "segment violation".
And I don't know how to append the read text instead of overwrite it...
I'll be very pleased if someone could give me an idea or if anybody could tell me something about preprocessing that.Code:#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *fuente;
FILE *destino;
fuente = fopen(argv[1], "r");
destino = fopen("prueba.php", "w");
char *linea;
int tam = 999;
if (fuente == NULL) {
printf("El fichero fuente no existe\n");
return(-1);
}
else{
while (!feof(fuente)){
fgets(linea,tam,fuente);
fputs(linea,destino);
printf("%s\n",linea);
}
fclose(fuente);
fclose(destino);
}
}
Thanks!!!