I'm having a bit of a problem and I cannot figure it out.

It seems as though code will only write to one keyname

I have an inifile

[section]
key1=
key2=
key3=

And my code
Class I'm using from http://www.codeproject.com/Articles/10809/A-Small-Class-to-Read-INI-File

stringstream ss (stringstream::in | stringstream::out);
CIniWriter MyIniTest(".\\test.ini");
char out[20] = {'/0'};
char out2[20] = {'/0'};

__Int64 int1 = 65777342;
__Int64 int2 = 63797342;

ss << int1;
ss >> out;
MyIniTest.WriteString("section", "key1", out);//working

ss << int2;
ss >> out2;
MyIniTest.WriteString("section", "key2", out2);//not working

Nothing I write to key2, key3, key4 etcetera will work, it will only write to key1, even if I change the first write, to key2 it will not work.

I have to say, I am tatally stumped.

Windows 7 32 bit, visual studio 2010.

Any help appreciated, thanks for reading.

lines 3 and 4 are wrong, it's '\0', not '/0'

you have to clear the stringstream before re-using it. Put this after line 12

ss.clear();
ss.seekp(0); // for outputs: seek put ptr to start
ss.seekg(0); // for inputs: seek get ptr to start

Must have been looking at it too long, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.