Search Results - CodeGuru Forums
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: 2kaud

Page 1 of 80 1 2 3 4

Search: Search took 0.12 seconds.

  1. Replies
    5
    Views
    89

    Re: Validating a Float

    As monarch_dodra says, why not use stream extraction? Why not do for float what was done for your other input validation? Consider


    #include <iostream>
    #include <limits>
    using namespace std;
    ...
  2. Replies
    5
    Views
    87

    Re: Multipad / superpad sample

    In c++ use istream to open an input stream for the file and getline() to read the file one line at a time until no more lines in the file
    See...
  3. Replies
    51
    Views
    655

    Re: Need help on errors (compilation issues)

    Just because it compiled OK with an older compiler doesn't mean it will with a newer one or a different one. Compilers change, the language changes. Without you posting the code in question we can't...
  4. Replies
    51
    Views
    655

    Re: Need help on errors (compilation issues)

    error C4716: 'Vector::NormalizeInPlace' : must return a value

    isn't this error self evident? This function is defined as having a return value and there is at least one return path from the...
  5. Replies
    51
    Views
    655

    Re: Need help on errors (compilation issues)

    Please do not provide links to sites when asking for assistance. Please post your code direct to the thread. See http://forums.codeguru.com/announcement.php?f=7

    When posting code, please use code...
  6. Re: Is stdext::hash_map's thread safe in free run environment?

    No. If shared data can be changed, then the data needs to be thread protected during the update. The only time you don't need to protect is if the data is read-only. I don't know the structure of the...
  7. Replies
    17
    Views
    432

    Re: Help! free() invalid pointer error

    Actually, you don't really need the temp buffer nor explicity null terminate *message. Consider (not tried)


    *message = (uint8_t*)calloc(size + 1, sizeof(uint8_t));

    for (int bytes = 0, ret =...
  8. Replies
    17
    Views
    432

    Re: Help! free() invalid pointer error

    *(message*+size) = '\0';


    assuming this is actual code, then should be


    *(*message + size) = '\0';


    but as others have requested, please post actual code.
  9. Re: Using malloc and free instead of new and delete in C++

    malloc() allocates one pointer to the area of memory of the size specified (in this case n objects of type T). Hence there needs to be only one free() that frees the pointer returned by malloc()....
  10. Re: Using malloc and free instead of new and delete in C++

    C++ rule. Always use new and delete. Don't use malloc() and free() unless there is a very, very good reason to.
  11. Thread: Input Validation

    by 2kaud
    Replies
    5
    Views
    132

    Re: Input Validation

    Laserlight is quite correct re this. As given the code in post #2 will accept 1abc as 1. This will leave abc in the input stream for the next extraction. If required then fine, if not then there a...
  12. Thread: Input Validation

    by 2kaud
    Replies
    5
    Views
    132

    Re: Input Validation

    Yeeessss... but you can use a while loop as stream extraction returns an istream object which can be checked. Consider



    #include <iostream>
    #include <limits>
    using namespace std;

    int...
  13. Re: concatenate int value from vector to long long int

    With VS2015 this gives "error C2146: syntax error: missing ']' before identifier 'Cn'". Although [&Cn] is OK.



    Yet another way! This though is probably the easier to read. I would be interested...
  14. Re: concatenate int value from vector to long long int

    but VS2015 doesn't :(

    error C3493: 'Cn' cannot be implicitly captured because no default capture mode has been specified
  15. Replies
    8
    Views
    215

    Re: How to break for loop

    See https://msdn.microsoft.com/en-us/library/windows/desktop/ms646268%28v=vs.85%29.aspx for details of using keyboard input.
  16. Replies
    17
    Views
    432

    Re: Help! free() invalid pointer error

    malloc() and bzero() should be size + 1 but recv() should be size so that the final char in buffer is always 0 to null-terminate. Is snprintf() off by 1??

    But why use snprintf? Why allocate/free...
  17. Re: concatenate int value from vector to long long int

    Consider


    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <numeric>
    using namespace std;

    int main()
  18. Re: concatenate int value from vector to long long int

    I think something like this. Consider


    #include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;

    int main()
    {
  19. Replies
    12
    Views
    241

    Re: Divide 1d vector into 2d vector

    The observed issue happens in configuration debug mode because the iterator is incremented beyond the end of the vector before tests are done for this situation. This is fine for a vector in release...
  20. Replies
    12
    Views
    241

    Re: Divide 1d vector into 2d vector

    Works OK for me in compile configuration release mode with VS 2015.
  21. Replies
    12
    Views
    241

    Re: Divide 1d vector into 2d vector

    3U means 3 of type unsigned - U for unsigned.

    What compiler are you using? You may need to replace constexpr with const. Basically constexpr means a const expression that can be evaluated at...
  22. Replies
    12
    Views
    241

    Re: Divide 1d vector into 2d vector

    From your OP, one way of obtaining the partition could be


    #include <vector>
    #include <iostream>
    #include <algorithm>
    #include <iterator>
    #include <cmath>
    using namespace std;
  23. Thread: cin statement

    by 2kaud
    Replies
    3
    Views
    159

    Re: cin statement

    Typed characters from the keyboard in response to cin requiring input are always echoed to the screen at the position of the cursor. To position the cursor before input is required then cout is used...
  24. Replies
    1
    Views
    145

    Re: How to implement a callback function

    This is a very simple example of using a callback function


    #include <string>
    #include <iostream>
    using namespace std;

    void fcb1()
    {
    cout << "In call 1" << endl;
  25. Replies
    11
    Views
    552

    Re: Review Component Based Architecture API

    For production non-real time code, it is nearly always the case that exceptions should be used rather than error codes. Good practice is to document the case(s) (with reason!) where error codes are...
Results 1 to 25 of 2000
Page 1 of 80 1 2 3 4


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a Codeguru.com survey!


HTML5 Development Center