Search:

Type: Posts; User: thmm

Page 1 of 6 1 2 3 4

Search: Search took 0.01 seconds; generated 56 minute(s) ago.

  1. More in the spirit of C++ is to use std::array.

    More in the spirit of C++ is to use std::array.
  2. @Schol-R-LEA-2...

    @Schol-R-LEA-2,

    yes, it's not 100% what you look for. Maybe you can add to it or modify it. Might be easier than starting from scratch.
  3. I think it's useful, but sth. like this exists...

    I think it's useful, but sth. like this exists already.
    GitHub - boostorg/safe_numerics: Replacements to standard numeric types which throw exceptions on errors
    Safe Numerics - develop
  4. Your data looks like JSON, so using a JSON...

    Your data looks like JSON, so using a JSON library might be a good idea.
  5. I see. So it's more an API problem.

    I see. So it's more an API problem.
  6. Shouldn't the compiler be able to warn when...

    Shouldn't the compiler be able to warn when passing a const char* to a function that accepts a char* ?
  7. Replies
    6
    Views
    1,132

    I would use this structure // compile with...

    I would use this structure

    // compile with -std=c99

    #include <stdio.h>
    #include <stdbool.h>


    int main()
    {
  8. I would recommend "Programming Windows" by...

    I would recommend "Programming Windows" by Charles Petzold. It's still the classic about Windows Programming.
    https://www.amazon.co.uk/gp/product/B00JDMP71S/ref=dbs_a_def_rwt_hsch_vapi_tkin_p1_i2
  9. Replies
    6
    Views
    1,132

    while (gals != -1) This will never be true...

    while (gals != -1)

    This will never be true because gals is an unsigned int.

    Add a simple print statement after L23 to see the value of gals when you enter -1
  10. Replies
    2
    Views
    25,751

    Have a look at the answers there. Why you don't...

    Have a look at the answers there.
    Why you don't want to use an IDE like MonoDevelop.
    MonoDevelop | MonoDevelop

    Why don't you use .NET Core? It runs on Windows, Mac and Linux. I am not sure if...
  11. Thread: why not working?

    by thmm
    Replies
    8
    Views
    984

    It's the same code you posted + the include. You...

    It's the same code you posted + the include.
    You also need to set the C++ Language Standard
    16476
  12. Thread: why not working?

    by thmm
    Replies
    8
    Views
    984

    You also need to include , then it works...

    You also need to include <ranges>, then it works with my VS2019
  13. The code you found looks very c-ish. It's much...

    The code you found looks very c-ish.
    It's much easier to check.


    bool is_palindrome(const std::string& s){
    std::string tmp(s.rbegin(), s.rend());

    return s == tmp;
    }
  14. I have difficulty understanding what you want to...

    I have difficulty understanding what you want to do.
    It seems you want to implement different categories, but how do they differ. ?
    Implementing a product with a category shouldn't be so...
  15. BTW. According to C++ guidelines raw pointers...

    BTW. According to C++ guidelines raw pointers should not be used.
    C++ Core Guidelines
    So a better option is to use either std::unique_ptr or std::shared_ptr.

    For a kind of static polymorphism...
  16. You can't pass variables to a template because...

    You can't pass variables to a template because everything must be known at compile time.
    You specify types or constant numbers, like:
    std::vector<int> v;
    std::array<int, 3> a;
  17. Replies
    5
    Views
    790

    ptr = malloc( 2 * sizeof(*ptr)); Your code...

    ptr = malloc( 2 * sizeof(*ptr));

    Your code and your intention don't match.
    Don't you see the problem ?

    ptr++; This looses the address of the original pointer.
  18. Replies
    12
    Views
    1,126

    Good idea.

    Good idea.
  19. Replies
    12
    Views
    1,126

    Using an array of counters would be an...

    Using an array of counters would be an alternative - works also for unsorted arrays.


    #include <stdio.h>

    #define NUM_DIGITS 9

    int main ()
    {
    int Digits[NUM_DIGITS] = {1, 1, 1, 2,...
  20. Replies
    2
    Views
    1,023

    You don't need to store the text. You can read...

    You don't need to store the text. You can read the file char by char and check if if is a letter.


    #include <iostream>
    #include <fstream>


    int main()
    {
    if(std::ifstream input{__FILE__})
  21. Replies
    10
    Views
    788

    clang and GCC have a memory sanitizer - have you...

    clang and GCC have a memory sanitizer - have you tried that ?
    gcc comes with sanitizer tool to use - TechnologyRelated
  22. Replies
    8
    Views
    20,623

    What errors do you get ? I would break up the...

    What errors do you get ?
    I would break up the code into 2 different functions. One to calculate for men and one for women
  23. Replies
    2
    Views
    505

    Well, you know how to print a prompt and get user...

    Well, you know how to print a prompt and get user input already. Just do it again.
    To compare the input with some value you can use strcmp from string.h
  24. One problem with mmap is that it is not standard,...

    One problem with mmap is that it is not standard, it's Linux only.
    If you don't bother about compatibility then go ahead.

    BTW. Have you decided to use C instead of C++ ?
    I noticed you also have...
  25. Replies
    5
    Views
    1,586

    When casting you might get over- / underflow...

    When casting you might get over- / underflow problems. To avoid this problem the GSL has a type gsl::narrow that detects this problem.
    GitHub - gsl-lite/gsl-lite: gsl-lite – A single-file...
Results 1 to 25 of 143
Page 1 of 6 1 2 3 4