Quotation Marks in Array Problem please help :)

Hi guys,

I am trying to do some image processing using the CImg library. I have an array of .hdr file called file_names names that appear like this:
image1.hdr
image2.hdr
image3.hdr
image4.hdr
and so on.

I want to use this array to introduce them to CImg like this: CImg<unsigned char> im("file_names[1]"). However, I can't do that because quotation marks are needed and when I do that it does not read "file_names[1]" as the first value of filename but instead as a different thing. How can I edit the array such that it looks like:
"image1.hdr"
"image2.hdr" etc or any other way to access the names of the arrays for the im().

Thanks!
Last edited on
A C-style string (array of char terminated by a NULL character) can either be a referenced by a char* (pointer to a char) or by a string literal (which is also technically a const char*, but doesn't look like it in the code).

Your file_names array is probably an array of char* (or, less likely, a 2-dimensional array of char). In this case, file_names[1] is a pointer and is all you need. You ONLY need quotation marks when you are using a string literal in your code. Since you are using a pointer, the quotation marks are not needed.

By the way, remember that the first string in your file_names array is actually file_names[0].
thank you!
Topic archived. No new replies allowed.