以下应用程序因空指针而崩溃。我想知道怎么了...
#include "stdio.h"
#include "string.h"
char* getFileData(char* fileName);
bool createShader( int shaderType, const char* shader, const char* shaderFile ) ;
void glShaderSource(int shader, int count, const char** string, const int* length);
int main(int argc, char* argv[])
{
char* shader = getFileData("filea.csd");
bool success = createShader(1, shader, "filea.csd");
return 0;
}
char* getFileData(char* fileName) {
if(!strcmp(fileName, "filea.csd"))
return "this is the content of the file a\0";
else if(!strcmp(fileName, "fileb.csd"))
return "this is the content of the file b\0";
else if(!strcmp(fileName, "filec.csd"))
return "this is the content of the file c\0";
else
return "";
}
bool createShader( int shaderType, const char* shader, const char* shaderFile )
{
int shaderHandle = 122;
glShaderSource( shaderHandle, 1, &shader, NULL ); ////This line is where it crashes.
return true;
}
void glShaderSource(int shader, int count, const char** string, const int* length) {
}