I made a win32 application in Visual C++ 2008 using the Windows Forms Application. But for opening files, and saving eventually, havn't gotten to it yet, I was creating some basic classes in other files.
The odd thing is the stdio.h file seems to be working differently in VC. I tried compiling the same code in Code::Blocks, which worked without problems.. Yet VC is still giving me a hard time figuring out what exactly is wrong.
Map.cpp
#include "stdafx.h"
#include "Map.h"
#include <stdio.h>
Map Map::openMap(Stringgg fileName)
{
Map theMap;
int x,y;
char myString[1000];
const char* FileName = fileName.GetStringgg();
File* pFile;
pFile = fopen(FileName, "r+b");
if(pFile != NULL)
{
fgets(myString, 1000, pFile);
fscanf(pFile, "%d %d", &x, &y);
theMap.SetName(fileName);
theMap.SetX(x);
theMap.SetY(y);
while(!feof)
{
fgets(myString, 1000, pFile);
int ID, z;
fscanf(pFile, "%d %d %d %d", ID, x, y, z);
}
}
else
{
theMap.SetName("New map");
theMap.SetX(200);
theMap.SetY(200);
Stringgg Error = "Couldn't open map. Creating new map(200x200)...";
MessageBox(NULL, Error, NULL, MB_OK);
return theMap;
}
}
Map.h
#ifndef MAP_H_INCLUDED
#define MAP_H_INCLUDED
#include "Position.h"
#include "String.h"
class Map
{
public:
Map() {}
Map(int x, int y): itsX(x), itsY(y) {}
~Map() {}
Stringgg GetName() {return itsName;}
int GetX() {return itsX;}
int GetY() {return itsY;}
//Position GetPosition(int x, int y, int z);
Stringgg SetName(Stringgg name) {itsName = name;}
void SetX(int x) {itsX = x;}
void SetY(int y) {itsY = y;}
//Position SetPosition(int x, int y, int z, int ID);
Map openMap(Stringgg fileName);
//void saveMap(Stringgg fileName);
private:
Stringgg itsName; //Name of the map
int itsX; //Size of the map; x-axis
int itsY; //Size of the map; y-axis
Position* itsPositions; //Positions on the map
};
#endif //MAP_H_INCLUDED
Don't mind the functions that are commented out in Map.h.. Left them out as I'm still stuck.
Stringgg is just a self-made string class because the windows String class was refusing to be used inside the classes for some reason... Called that way to avoid the names being ambigous. Position is another class in a seperate header file.
Neither of them is really needed, since the errors:
1>Compiling...
1>Map.cpp
1>.\Map.cpp(12) : error C2065: 'File' : undeclared identifier
1>.\Map.cpp(12) : error C2065: 'pFile' : undeclared identifier
1>.\Map.cpp(13) : error C2065: 'pFile' : undeclared identifier
1>.\Map.cpp(15) : error C2065: 'pFile' : undeclared identifier
1>.\Map.cpp(17) : error C2065: 'pFile' : undeclared identifier
1>.\Map.cpp(18) : error C2065: 'pFile' : undeclared identifier
1>.\Map.cpp(22) : warning C4551: function call missing argument list
1>.\Map.cpp(24) : error C2065: 'pFile' : undeclared identifier
1>.\Map.cpp(26) : error C2065: 'pFile' : undeclared identifier
1>.\Map.cpp(35) : error C2065: 'MB_OK' : undeclared identifier
1>.\Map.cpp(35) : error C3861: 'MessageBox': identifier not found
Somehow seems as if the "stdio.h" doesn't recognize the type File.. Yet considering MessageBox gives an error too there's probably something else wrong too..
Or that might just because I forgot to include something..
Thanks for any input.. [Probably something stupid anyway]