glDrawArrays triggers Access Violation

It says “character strings”, which would be something like
GLchar string1 = {‘S’, ‘T’, ‘R’, ‘1’, ‘\0’};

No, that is a character array. An array of characters = 1 string. Character string[b]s/b would be several of those character arrays, like this:


mystring[0][] = {'S', 'T', 'R', '0', '\0'};
mystring[1][] = {'S', 'T', 'R', '1', '\0'};
mystring[2][] = {'S', 'T', 'R', '2', '\0'};

Technically thats not compilable code, but its meant to drive home the point that mystring is an array of character arrays(strings). Read what Alfonse said carefully. It should make sense after a couple of readings hopefully.

The only thing I don’t understand is Alfonse’s follwing statement:

What you gave it is an array of pointers to each character of the same string. What it asked for was an array of pointers to different strings.

I don’t see that. I didn’t give pointers to each character of the same string. I gave pointers do different strings, which together make up the sourcefile.
Maybe the name of the vector holding the pointers is chosen unlucky, since CArray implies that it is actually an array of GLchars and not and array of pointers to const GLchars (which it is).

Greetings,
OGLBeginner

PS: I now know what the real problem with my code was: It stripped the newlines, as Alfonse said, which seems to be a problem for the compiler, even though only null-terminated strings are expected. The following code works:

	vector<string> LineBuffer;
	while (File) {
		string Line;
		getline(File, Line);
		Line += '
';
		LineBuffer.push_back(Line);
	}

I know this is way over the top, but at least it’s working now. Of course I’m going to use Alfonse’s approach instead.

Yes I think Alfonse missed the bit about LineBuffer being a vector rather than a single string…

I dont think what you are doing is all that bad either. Its just a different approach. You use a vector rather than streaming, and you do more error-checking.