quote:
Originally posted by Millenium_edition
Yesterday I realized my MSN servers app was widely used... So I decided to make a new version, with new features and stuff. But i wanted to do it in c++.
My problem: i get a bug, and I don't understand why
I wrote this piece of code to try to get the number of servers.
code:
#include <windows.h>
#include <fstream.h>
int GetEntries(char* buffer, long int size);
int main(int argc, char* argv[])
{
fstream servers("msnservers.dat",ios::in | ios::binary | ios::ate);
long int fileSize;
fileSize = servers.tellg();
char* fileBuffer;
fileBuffer = new char[fileSize];
servers.seekg(0);
servers.read(fileBuffer,fileSize);
servers.close();
int entries=GetEntries(fileBuffer,fileSize);
MessageBox(0,reinterpret_cast<const char*>(entries),'\0',0);
delete[] fileBuffer;
return 0;
}
int GetEntries(char* buffer, long int Size) {
char tempchar;
int temp = 0;
for(int i = 0; i < Size; i++) {
tempchar=buffer[i];
MessageBox((HWND)0,reinterpret_cast<const char*>(tempchar),'\0',0);
}
return temp;
}
it gives me the ugly XP crash box. (I'm using ms vc++ 6 as a compiler, and I'm happy with it.)
Now, could someone please tell me what's wrong?
The compiler? I = total n00b in C++, but have you tried using a different compiler? I was doing a VB program in school once and I had to use a different compiler because VBStudio didn't work. Had to eventually get it reinstalled.