PDA

View Full Version : Can someone write this simple program . . .



Schlogenburg
05-30-2000, 02:41 PM
I've been trying for hours and hours trying to make a ASCII text file loader, that simply loads filenames (blah.bmp) out of the text file.
I've been having tons of trouble reading and writing files, so if someone could write this simple example, where it puts the filenames in an array, I'd be extremely gratefull. I've already looked at tutorials also, they don't help much because it's hard to see what's going on in an OpenGL application.

05-30-2000, 03:23 PM
Schlos, what kind of restrictions do u put on ur file format?

dmy
05-31-2000, 04:24 AM
not very opengl... lionhead board is better at this.
just a hint: open your file as binary and read char by char!

Dolo/\/\ightY

06-01-2000, 11:22 AM
Assuming you're using C/C++, and ignoring the OpenGL part of the prog,

#include <stdio.h>

void main(void)
{
FILE *inout;
char buffer[20][20];

inout=fopen("text.dat", "rt");
for (int n=0;n<=20;n++)
fscanf(inout,"%s",buffer[n]);

fclose(inout);
}