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. Advertising

  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. Advertising

  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. Advertising

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. Gustavo De la Espriella

    How to make an application Database independant

    Gustavo De la Espriella, Feb 3, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    448
    Matt Berther
    Feb 8, 2005
  2. Gustavo De la Espriella
    Replies:
    5
    Views:
    1,062
    Matt Berther
    Feb 8, 2005
  3. Schnoffos
    Replies:
    2
    Views:
    1,195
    Martien Verbruggen
    Jun 27, 2003
  4. Hal Styli
    Replies:
    14
    Views:
    1,609
    Old Wolf
    Jan 20, 2004
  5. Replies:
    4
    Views:
    591
    Jim Langston
    Oct 2, 2006
Loading...

Share This Page