-
Reading file...
I have a file that its content is like this:
Code:
MatName: "Mat1"
{
Ambient: 1 0 0 1
Diffuse: 1 0 1 1
}
MatName: "Mat2"
{
Ambient: 1 0 1 1
Diffuse: 0 0 0 1
}
for example. What I am trying to do is a function taht loads this file and takes a parameter MaterialName (f.e "Mat1", "Mat2", etc). How can I make the program to read only the block that the specified name is present?
-
Code:
pesudocode
Object * fun1( const char * name )
{
read one object from file
if( object name == name )
return object
else
keep reading
}
That should get you started. Make one function that reads an entire "object" and returns it to this function. This function then compares it, and if found, returns that object. Otherwise, it keeps reading.
Post your code, your errors, and where you're stuck.
Quzah.
-
Ok I am using that already for something else so I get your point. Do you know any tutorial on fseek, sscanf, fscanf functtions?
-
There are plenty of sites that offer tutorials and example code. Have you tried searching these boards?
-