Original Post
Hi All!
I''ve been having a bit of a problem searching strings. Here''s what I''m trying to do. I have create a string like so:
char *extensions;
I then use an opengl function to get a list of all available extensions, seperated by spaces.
extensions = (char*)glGetString(GL_EXTENSIONS);
Now, I need to find out if the text "GL_ARB_multitexture" is in that string. I have tried the following meathods, all of which seem to crash for some reason. For all of the following, the result is an unhandled exception, and debugging always leads back to the search function.
if(strstr(extensions, "ARB_multitexture") != NULL))
{ do stuff; }
and also using the following search function:
Any help will be GREATLY appreciated. Oh yea, and I also tried the meathod that NeHe uses on his page... No luck... Thanks again!
Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"
bool InStr(char *searchStr, char *str)
{
char *extension; // start of an extension in the list
char *endOfStr; // pointer to last string element
int idx = 0;
endOfStr = str + strlen(str); // find the last character in str
// loop while we haven''t reached the end of the string
while (str < endOfStr)
{
// find where a space is located
idx = strcspn(str, " ");
// we found searchStr
if ( (strlen(searchStr) == idx) && (strncmp(searchStr, str, idx) == 0))
{
return true;
}
// we didn''t find searchStr, move pointer to the next string to search
str += (idx + 1);
}
return false;
}