Having trouble with ifstream and getline... :\

Ok, so the problem is that I use getline(my_ifstream,my_string,my_char);
and after that is done, my_string is empty.
I really don't get it, and I will post the code if requested.
Help!
closed account (S6k9GNh0)
You should post the code originally.
ok. Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
ifstream in(filename, ios::in);
string input = " ";
string input2 = " ";
input = in.get();
getline(in,input,']');
in.ignore(numeric_limits<streamsize>::max(),'\n'); //Ignoring untill the next line
getline(in,input,'='); //Reading the Keyword
cout << "input1 = " << input << endl;
getline(in,input2,';'); //Reading the Value
cout << "input2 = " << input2 << endl;
basic_vals.push_back(obj(input,input2));
in.ignore(numeric_limits<streamsize>::max(), '\n'); //Ignoring till the next lie
getline(in,input,'='); // Reading the Keyword
cout << "input1 = " << input << endl;
getline(in,input2,';'); // Reading the Value
basic_vals.push_back(obj(input,input2));
in.ignore(numeric_limits<streamsize>::max(), '\n'); //Ignoring till the next line
getline(in,input,'='); //Reading the Keyword
cout << "input1 = " << input << endl;
getline(in,input2,';'); //And the Value
cout << "input2 = " << input2 << endl;
basic_vals.push_back(obj(input,input2));
in.ignore(numeric_limits<streamsize>::max(), '\n');
Last edited on
closed account (S6k9GNh0)
Please make a test case...
Here is a sample text doc:

[Basic]
Name=My Map;
Width=5;
Height=5;

[Keys]
G=Images\Basic Grass.png;
S=Images\Basic Snow.png;
W=Images\Basic Water.png;

[Map]
R1C1=G;R1C2=G;R1C3=G;R1C4=G;R1C5=W;
R2C1=S;R2C2=S;R2C3=G;R2C4=W;R2C5=W;
R3C1=W;R3C2=G;R3C3=S;R3C4=S;R3C5=S;
closed account (S6k9GNh0)
http://en.wikipedia.org/wiki/Test_case
Computerquip, I have no positive cases, and I only have one text document that I am using. It fails.

I found the problem. The ifstream is not even opening the file. Thanks!
Topic archived. No new replies allowed.