apologies if this is a basic question but I haven't been able to figure it out from other posts. I'm trying to read a bunch of images that are labelled "1.jpg"
"2.jpg"
"3.jpg"
etc. I'd like to do so using a for loop. The file reader (I'm using SOIL here, as recommended in the OpenGL nehe tutorial I'm following), requires a const char*
as the filename input.
char numbers[6] = "123456";
for (int i=0;i<6;i++)
{
const char* filestring = new char[5];
*filestring = numbers[i] + ".jpg";
texture[i] = SOIL_load_OGL_texture(filestring, ...
... // filestring should be const char* form
}
The errors are:
(1) error: initializer-string for array of chars is too long [-fpermissive]
but i don't see what is wrong with char numbers[6] = "123456"
?
error: assignment of read-only location '* filestring'
error: invalid conversion from 'const char*' to 'char' [-fpermissive]
I'm a bit baffled. Would be grateful for any advice!
Thanks.