dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22

Thread: unexpected behavior of integer variable

  1. #16
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,972

    Re: unexpected behavior of integer variable

    For those that took the time to answer my stupid questions
    Those were not stupid questions. Here at codeguru we try to help as much as we can - irrespective of knowledge.

    Merry Christmas.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.4.2)

  2. #17
    Join Date
    Dec 2019
    Posts
    23

    Re: unexpected behavior of integer variable

    When I use equal in place of assign then there is no output to the string. Also, the code window error check doesn't like me using assign. I do what ever it takes to achieve the result that I want. The need for the std::string numstr variable is that I enter the fractional decimal via a keypad. Therefore, I have to store the string digits in a string and then do the type conversion. There may be other ways of skinning that cat but the type conversion is the simplest and cleanest way that I know of. I have seen people use and int value to store the value as a whole number and by tracking the decimal point us the pow function to create a fractional decimal. That looks very messy to me.

    Thanks for your patience and help,
    Ron

  3. #18
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,208

    Re: unexpected behavior of integer variable

    Quote Originally Posted by OldRon View Post
    When I use equal in place of assign then there is no output to the string. Also, the code window error check doesn't like me using assign. I do what ever it takes to achieve the result that I want. The need for the std::string numstr variable is that I enter the fractional decimal via a keypad. Therefore, I have to store the string digits in a string and then do the type conversion. There may be other ways of skinning that cat but the type conversion is the simplest and cleanest way that I know of. I have seen people use and int value to store the value as a whole number and by tracking the decimal point us the pow function to create a fractional decimal. That looks very messy to me.

    Thanks for your patience and help,
    Ron
    You'll need to set some breakpoints and step through the code. Then hover over the variables to see their values. From there you can figure out why something isn't working.

    Btw, the latest VS version helps here (or latest - 1) because not many of us have old versions installed. There are slight changes to debugging operations which the older versions may not support. For example, I don't remember if vs 2010 supports c++ variable inspection by hovering. Maybe it does, but if not, it's going to be frustrating if someone mentions doing something that isn't supported on an older version.

  4. #19
    Join Date
    Dec 2019
    Posts
    23

    Re: unexpected behavior of integer variable

    On your suggestion I downloaded and installed Visual Studio 2019. It is licensed through the user's Microsoft account. I got my program completed by using a collage of prototypes that I wrote and the Arduino debugger spit it out like Monopoly money at an ATM. I was starting to like C++ but as was suggested I will have to work in C.

    Ron

  5. #20
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,972

    Re: unexpected behavior of integer variable

    I did a couple of own Arduino projects a few years ago using the Arduino IDE - and from what I remember there were some differences/incompatibilities between 'standard C++' and Arduino C++. I sorted these out using the on-line Arduino language reference.

    You may be interested in knowing about Arduino IDE For Visual Studio. See https://marketplace.visualstudio.com...orVisualStudio
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.4.2)

  6. #21
    Join Date
    Dec 2019
    Posts
    23

    Re: unexpected behavior of integer variable

    2kaud,

    Thank you for the link. Happy New Year and may you have many to come.

    Ron

  7. #22
    Join Date
    Feb 2017
    Posts
    506

    Re: unexpected behavior of integer variable

    Quote Originally Posted by OldRon View Post
    I was starting to like C++ but as was suggested I will have to work in C.
    You don't have to skip C++ altogether. You can still use elements of C++ to your advantage without taking on the full modern C++. As I mentioned in #11, one example is the standard STL data structures. I certainly would prefer std::vector over static C arrays.

    If you need moral support for staying away from C++ I offer this now classic rant from Linus Torvalds, the inventor of Linux,

    http://harmful.cat-v.org/software/c++/linus

    Personally I don't agree in general but Linus is programming an OS kernel and for that I think he has a point. I suppose the stuff you tend to do with Arduino UNO is also quite close to the metal. That's why sticking with C may be a good option mostly because you save yourself from a time-consuming uphill battle with a notoriously difficult language like C++ that in the end may not even add much value to your particular application.

    Good Luck!
    Last edited by wolle; December 27th, 2019 at 03:13 PM.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)