i forget how it's done: read lines from .txt

Started by MisterN, April 11, 2013, 11:24:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MisterN

i forgot how it's done since I haven't used it in awhile and I can't find the thread that had the information and how to use it. how can I read this .txt file:
Quote*moving left
left
*moving right
right
*shooting
control
*jumping
alt
Quote
and putting each line into string conkey[8];
thanks
werg

handsource-dyko


something a bit like this (more or less)



textfile_id = fopen ("commands.txt", O_READ);


for (c = 0; c < 8; c++)
     conkey [c] = fgets (textfile_id);
end
   
fclose (textfile_id);
[size=78%]




b.t.w. do also mean to interpret the commands? you can use the strcasecmp() or find() functions to test if line contains valid input, and act accordingly.

[/size]

MisterN

i am using this
menu.conkey_map = fopen("conkey.txt", O_READ);
for (c = 0; c < 8; c++)
     conkey [c] = fgets(menu.conkey_map);
end 
fclose(menu.conkey_map);

it says it does not know what o_read is. these are what i have loaded in the beginning
import "mod_grproc";
import "mod_wm"
import "mod_key"
import "mod_proc"
import "mod_video"
import "mod_text"
import "mod_map"
import "mod_draw"
import "mod_debug"
import "mod_say";
import "mod_screen";
import "mod_math";
import "mod_time";
import "mod_dir";
import "mod_joy";
import "mod_sound";
import "mod_rand";


thanks
werg

panreyes


MisterN

thank you very much. ive been working on my engine in bits, and when i finish every little detail of each part, ill join them together. ive learned my lesson on that lol xD
werg

handsource-dyko

Joining things together. That's an exciting part, that's where the design of a project starts to show it's effect. I've learned my lessons too.
I have started a new project because my editor's gui is showing it's limitations. I have just started on creating a simple gui library but it's in a very early stage. But I'm not sure of it will have textinput because it's kinda complicated to get right. I am waiting for a new version of the android packager so I can finally get malvado on android. (samsung has recently updated my devices to android 4.1).