CString changing an independant int

Discussion in 'C++' started by Rob Prins, Aug 1, 2008.

  1. Rob Prins

    Rob Prins Guest

    { 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

    --
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]
    [ comp.lang.c++.moderated. First time posters: Do this! ]
     
    Rob Prins, Aug 1, 2008
    #1
    1. Advertisements

  2. Rob Prins

    red floyd Guest

    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++ (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).

    --
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]
    [ comp.lang.c++.moderated. First time posters: Do this! ]
     
    red floyd, Aug 1, 2008
    #2
    1. Advertisements

  3. Rob Prins

    Alex Shulgin Guest

    On Aug 1, 5:04 am, Rob Prins <> 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! ]
     
    Alex Shulgin, Aug 11, 2008
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Schnoffos
    Replies:
    2
    Views:
    1,504
    Martien Verbruggen
    Jun 27, 2003
  2. Hal Styli
    Replies:
    14
    Views:
    2,080
    Old Wolf
    Jan 20, 2004
  3. arun
    Replies:
    8
    Views:
    734
    Dave Thompson
    Jul 31, 2006
  4. aling
    Replies:
    8
    Views:
    1,765
    Jim Langston
    Oct 20, 2005
  5. Replies:
    4
    Views:
    782
    Jim Langston
    Oct 2, 2006
  6. Replies:
    9
    Views:
    665
    James Kanze
    Apr 17, 2007
  7. Replies:
    19
    Views:
    627
  8. powerhouse04
    Replies:
    1
    Views:
    458
    powerhouse04
    Dec 16, 2007
Loading...