Problems with file manipulation... HELP!

Posted By: fireapach3

Problems with file manipulation... HELP! - 01/13/10 18:54

Hey folks! I have a problem that are kiling my brain! It's really simple, load the contents of the file that i call teste.txt and it's in the same folder of the Script .c ...

Just when i start the aplicattion, this appears:


This is the contents of teste.txt:
Code:
0001: Aqui é o meu lugar pai!
0002: Não me obrigue a fazer isso filho!
0003: NÃO PAI!!!
0004: HAHAHA!!!
// Não é para lêr esta linha!!!
0005: NÃOOO!!!
0006: BOOM!!!
0007: (Silêncio)



Well, i will create a function to locate the strings in the file and use in the subtitles in the game...

But this f*&% error in file_str_read appear on the screen and says the 2° argument is wrong: STRING!

Here is the .c file:
Code:
#include <acknex.h>
#include <default.c>

STRING* Legenda;

var a;
var b;

function main()
{
	a = file_open_game("teste.txt");
	b = file_find(a, "0003:");
	file_str_read(b, Legenda);
	file_close(a);
	draw_text(Legenda, 10, 10, vector(0, 0, 120));
}



I really need this to continue the game! PLZ, help!
Posted By: DJBMASTER

Re: Problems with file manipulation... HELP! - 01/13/10 19:08

Maybe it is because 'Legenda' is unitialized. Try replacing it with...
STRING* Legenda = " ";

Posted By: fireapach3

Re: Problems with file manipulation... HELP! - 01/13/10 20:40

Well... now the error do not appear, but the 3DGS CRASHES e shutdown! XD

Any problem with the function that i used?
Posted By: Lion_Ts

Re: Problems with file manipulation... HELP! - 01/14/10 21:35

i think, it was a good idea to initialize the string. but, seems, you're demaging the memory reading into the empty string laugh
allocate string with enough space to hold the data (like: STRING* line="#4000";)
© 2024 lite-C Forums