Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > CString changing an independant int

Reply
Thread Tools

CString changing an independant int

 
 
Rob Prins
Guest
Posts: n/a
 
      08-01-2008
{ 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++ (VS200. 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

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      08-01-2008
Rob Prins wrote:
> { 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++ (VS200. 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).

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

 
Reply With Quote
 
 
 
 
Alex Shulgin
Guest
Posts: n/a
 
      08-10-2008
On Aug 1, 5:04 am, Rob Prins <(E-Mail Removed)> wrote:
>
> 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...

--
Regards,
Alex


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What would this defintion mean: int Function(class CString filename) huguogang@gmail.com C++ 4 10-02-2006 07:31 AM
Difference between int i, j; and int i; int j; arun C Programming 8 07-31-2006 05:11 AM
int a[10]; int* p=(int*)((&a)+1); But why p isn't equal to ((&a)+1)? aling C++ 8 10-20-2005 02:42 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments