Search:

Type: Posts; User: thmm

Page 1 of 6 1 2 3 4

Search: Search took 0.01 seconds.

  1. Thread: why not working?

    by thmm
    Replies
    8
    Views
    827

    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
  2. Thread: why not working?

    by thmm
    Replies
    8
    Views
    827

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

    You also need to include <ranges>, then it works with my VS2019
  3. 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;
    }
  4. 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...
  5. 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...
  6. 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;
  7. Replies
    5
    Views
    702

    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.
  8. Replies
    12
    Views
    1,012

    Good idea.

    Good idea.
  9. Replies
    12
    Views
    1,012

    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,...
  10. 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__})
  11. Replies
    10
    Views
    695

    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
  12. Replies
    8
    Views
    20,437

    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
  13. Replies
    2
    Views
    409

    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
  14. 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...
  15. Replies
    5
    Views
    1,447

    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...
  16. Replies
    10
    Views
    721

    Just for info, your C++ version could be as...

    Just for info, your C++ version could be as simple as:

    std::string reverse(const std::string& str)
    {
    return std::string(str.rbegin(), str.rend());
    }

    Might be a good idea to focus on C++....
  17. Replies
    10
    Views
    721

    @OP, did you write the C++ code or did you...

    @OP,

    did you write the C++ code or did you find it somewhere ?
  18. Thread: If function

    by thmm
    Replies
    4
    Views
    670

    This is C code. Maybe someone can move it to the...

    This is C code. Maybe someone can move it to the right place.
  19. Replies
    6
    Views
    675

    Maybe you should use GDB online Debugger |...

    Maybe you should use GDB online Debugger | Compiler - Code, Compile, Run, Debug online C, C++
    It lets you specify extra compiler flags
  20. Replies
    5
    Views
    517

    I meant getchar(), was just a typo.

    I meant getchar(), was just a typo.
  21. Replies
    8
    Views
    782

    What doesn't work? Do you have compile errors,...

    What doesn't work?
    Do you have compile errors, linker errors, crashes....

    This trailing # looks suspicious
    #ifdef__linux__ #
  22. Replies
    5
    Views
    517

    I guess you run the .exe from Windows shell. It's...

    I guess you run the .exe from Windows shell. It's a common problem in Windows.
    If you run it in Code::Blocks, the IDE keeps the console window open for you.

    To solve the problem you can run your...
  23. Thread: square root

    by thmm
    Replies
    2
    Views
    534

    You need to link with the math library. Link in...

    You need to link with the math library.
    Link in the Math Library | C For Dummies Blog
  24. Replies
    4
    Views
    492

    Why would you want to copy a struct ? Pass it as...

    Why would you want to copy a struct ? Pass it as const pointer or const ref.
  25. Replies
    1
    Views
    340

    Much better to ask in English. Not many people...

    Much better to ask in English. Not many people here understand German.
Results 1 to 25 of 140
Page 1 of 6 1 2 3 4