Search:

Type: Posts; User: thmm

Page 1 of 7 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    6
    Views
    1,476

    It's always better to break down a task into...

    It's always better to break down a task into smaller tasks
    Maybe you can work with this skeleton


    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    void read_file(char* name){
    ...
  2. Thread: Structure pointer

    by thmm
    Replies
    5
    Views
    2,247

    A simple example might make it easier. ...

    A simple example might make it easier.

    #include <stdio.h>

    typedef struct
    {
    int X, Y;

    } Point;
  3. Replies
    2
    Views
    1,924

    Country isn't a float, it's a string and you...

    Country isn't a float, it's a string and you should read it as a string.
    Also you should skip the first line.
    Do you have to use different arrays ? It would be easier to use an array of structs.
    ...
  4. Replies
    6
    Views
    1,936

    Yor getFile could be simpler. vector...

    Yor getFile could be simpler.

    vector<double> getFile() {
    vector<double> input_from_file;
    fstream loaded_file("unsorted_numbers_short.dat");
    if (!loaded_file) {
    cout << "File not...
  5. More in the spirit of C++ is to use std::array.

    More in the spirit of C++ is to use std::array.
  6. @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.
  7. 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
  8. Your data looks like JSON, so using a JSON...

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

    I see. So it's more an API problem.
  10. 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* ?
  11. Replies
    6
    Views
    3,572

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

    I would use this structure

    // compile with -std=c99

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


    int main()
    {
  12. Replies
    1
    Views
    1,836

    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
  13. Replies
    6
    Views
    3,572

    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
  14. Replies
    2
    Views
    56,101

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

    by thmm
    Replies
    8
    Views
    3,132

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

    by thmm
    Replies
    8
    Views
    3,132

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

    You also need to include <ranges>, then it works with my VS2019
  17. 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;
    }
  18. 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...
  19. 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...
  20. 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;
  21. Replies
    5
    Views
    2,791

    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.
  22. Replies
    12
    Views
    3,928

    Good idea.

    Good idea.
  23. Replies
    12
    Views
    3,928

    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,...
  24. Replies
    2
    Views
    2,413

    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__})
  25. Replies
    10
    Views
    3,579

    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
Results 1 to 25 of 154
Page 1 of 7 1 2 3 4