CString changing an independant int

R

Rob Prins

{ This is probably a non-environment-specific problem buried in an
environment-specific context; thus accepted. -mod }

L.S.

For a couple of days I've been trying to write a small Windows program,
and although C is no problem I'm struggling witch C++ (VS2008). Somehow
I must be doing something wrong.

I've got this dialog class in which I've defined some ints and CStrings,
and some functions. What happens is this: in one of those functions I
assign a value to one of these CStrings (just strFoo = "bar";). At that
exact moment in the program the value of one of the class's ints changes
too. In C I'd know my string buffer was too small or something, but I
thought it would be impossible with a CString...

Probably a dumb question, but any answer is appreciated.

Thanks,

Rob
 
R

red floyd

Rob said:
{ This is probably a non-environment-specific problem buried in an
environment-specific context; thus accepted. -mod }

L.S.

For a couple of days I've been trying to write a small Windows program,
and although C is no problem I'm struggling witch C++ (VS2008). Somehow
I must be doing something wrong.

I've got this dialog class in which I've defined some ints and CStrings,
and some functions. What happens is this: in one of those functions I
assign a value to one of these CStrings (just strFoo = "bar";). At that
exact moment in the program the value of one of the class's ints changes
too. In C I'd know my string buffer was too small or something, but I
thought it would be impossible with a CString...
How do you know this? Is the debugger showing it? Have you done a
print of the int variable, to confirm it's not just an artifact of a
debugger.

And as the mod noted, CString is MFC specific. You really should try
to learn the Standard library (std::string).
 
A

Alex Shulgin

I've got this dialog class in which I've defined some ints and CStrings,
and some functions. What happens is this: in one of those functions I
assign a value to one of these CStrings (just strFoo = "bar";). At that
exact moment in the program the value of one of the class's ints changes
too. In C I'd know my string buffer was too small or something, but I
thought it would be impossible with a CString...

Probably a dumb question, but any answer is appreciated.

Care to post some minimal example? Most probably you are doing
something wrong elsewhere...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top