Hi I have a simple problem - I think.
I'm reading the content from a file into a char array:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
std::ifstream fileStream(name.c_str(), std::ios::binary | std::ios::ate);
if (fileStream)
{
int length;
//Get length of file
fileStream.seekg(0, std::ios::end);
length = fileStream.tellg();
fileStream.seekg(0, std::ios::beg);
char* buffer = new char[length];
fileStream.read(buffer, length);
return buffer;
}
|
It reads the input fine, but somehow the char array is too big? The content of the file is followed by some random chars?
[EDIT]
Im really confused. Here is the content from the file copied from notepadd++:
#version 330
layout(location=0) in vec4 in_Position;
layout(location=1) in vec4 in_Color;
out vec4 ex_Color;
void main(void)
{
gl_Position = in_Position;
ex_Color = in_Color;
}
And here's what I get from the debugger:
#version 330
layout(location=0) in vec4 in_Position;
layout(location=1) in vec4 in_Color;
out vec4 ex_Color;
void main(void)
{
gl_Position = in_Position;
ex_Color = in_Color;
}ýýýý««««««««îþ
I use visual studio 2010 on a windows 7.
Is it a encoding problem?
Any help how to solve this is really appreciated :)