Shader from files

Hi
I am new to GLSL. Right now I am reading the Book “OpenGL Shading Language Thrid Edition”. My problem is that I don’t know how I can load Shaders from files and use them with glShaderSource. Is there a way to that?

Hope that there are not too many spelling mistakes in my text.
Thank you.

It is quite simple. Just load a content of the file into a string and pass it to the glShaderSource() function. For example:

char* CGLShader::FileRead(CString fileName) 
{
	FILE *fp;
	char *content = NULL;

	int count=0;

	if (!fileName.IsEmpty()) {
		fp = fopen(fileName,_T("rt"));
		if (fp != NULL) 
		{
			fseek(fp, 0, SEEK_END);
			count = ftell(fp);
			rewind(fp);
			if (count > 0) 
			{
				content = new char [count+1];
				count = fread(content,sizeof(char),count,fp);
				content[count] = '\0';
			}
			fclose(fp);
		}
	}
	return content;
}