I'm using Bloodshed's Dev-C++ 4.9.8.0
Code:
from custom.h header:
#include <windows.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct PLAYER
{
string Name;
int Gold;
int Hp;
XP Xp;
WEAPON Weapon;
ARMOR Armor;
};
from main.cpp:
1 #include "custom.h"
2
3 int main()
4 {
5 PLAYER Player;
...
23 ifstream loadpname;
24 loadpname.open("playername.txt");
25 loadpname.getline(Player.Name, 50, '\n');
26 loadpname.close();
27
28 return 0;
29 }
Why wont the above read the first line in playername.txt?
The compiler says this:
25 C:\programs\Spil\main.cpp
no matching function for call to `std::basic_ifstream<char,
664 C:\Dev-Cpp\include\c++\bits\istream.tcc
candidates are:
176 C:\Dev-Cpp\include\c++\istream
std::basic_istream<_CharT,
doesn't getline(blah) take strings?
if it doesn't then how do I determine how long the line is? So I
can use an array. I can't seem to find how to do it anywhere...