Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

Graham Breach

@Graham Breach
About
Posts
293
Topics
5
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Please - explain the C++ code / function
    G Graham Breach

    I'm in agreement with Richard on what is actually happening there. It looks like the QStringList is being used to join all the arguments together to make a complete command line for passing to the QProcess. /bin/sh is the Bourne shell, you should be able to find the manual page for it online or by typing "man sh" in your Linux terminal. I don't know why it is using a shell instead of executing the command directly, but I suspect there is a good reason. Maybe for wildcard parsing or terminal I/O buffering.

    C / C++ / MFC c++

  • Please - explain the C++ code / function
    G Graham Breach

    The << in this is not shift left, it is operator<<() operating on whatever QStringList() returns. It might be concatenating them, or appending them to an array, or whatever. It can handle both char* and QString because it probably has overloads for both types, or possibly because QString has an operator for returning a char*. I'm guessing this from the context because the C++ standard library also uses << this way - you would have to consult the QT documentation to be sure.

    C / C++ / MFC c++

  • RegQueryValueExW vs RegQueryValueExA
    G Graham Breach

    Because sz is the size of the value in bytes, not characters. If you retrieve a string from the registry using RegQueryValueExA you get a string with 1-byte ASCII characters, and if you use RegQueryValueExW you get a string with 2-byte Unicode characters.

    C / C++ / MFC visual-studio help

  • Visual C++ 2022 cout bug?
    G Graham Breach

    Its working fine here on Windows 10, VS 17.5.5, so I would suspect the Windows 11 terminal - can you try running it in a cmd.exe window instead?

    C / C++ / MFC help c++ testing debugging beta-testing

  • How to "provide password " REMOVED
    G Graham Breach

    An easier option might be to configure sudo to allow the user of your program to call it without a password. The sudoers file is the place to do this. Obviously there may be security implications with this, but that is up to you to decide. Another alternative is to set the set-user-id bit on your executable so that it automatically runs as root (using chmod and chown). Again, this has security implications to think about.

    Linux Programming tutorial

  • PHP Fatal error: Uncaught TypeError: count()
    G Graham Breach

    Replacing count($row[0]); with strlen($row[0]); should do it.

    Linux, Apache, MySQL, PHP help php database mysql data-structures

  • Passing a pointer to object - using template - followup.
    G Graham Breach

    The part in <> should be a type and the compiler is complaining that it doesn't know what data_list is. If it is a type, make sure you include the correct header so that it can be found. If what you actually meant was for data_list to be the name of the function argument, it should be more like this:

    explicit Form_SetupLocalAdapter(QList<*DataListType> data_list);

    - replacing DataListType with the type (or base type) of data_list.

    C / C++ / MFC help question c++ tutorial

  • Basic C++ - can you explain the difference / function of each definition ?
    G Graham Breach

    The first one creates an instance on the stack. It will be destroyed when it goes out of scope. The second one creates an instance in heap memory*. It will not be automatically destroyed and you should call delete to destroy it. *Unless new has been overridden to do something unusual.

    C / C++ / MFC question c++

  • Heap Storage Corruption
    G Graham Breach

    C doesn't have new/delete at all - you are writing C++

    C / C++ / MFC data-structures

  • Heap Storage Corruption
    G Graham Breach

    You are using new[], so you must use a matching delete[]:

    char* t = new char[70];

    // do stuff with t

    delete[] t;

    This might not be the cause of the problem you are having, but it will cause problems.

    C / C++ / MFC data-structures

  • Invalid comparator for STL map
    G Graham Breach

    I think you're making it too complicated:

    struct ESDID
    {
    char c[4];

    bool operator<(const ESDID& other) const
    {
    return c[0] < other.c[0] && c[1] < other.c[1] &&
    c[2] < other.c[2] && c[3] < other.c[3];
    }
    }

    struct usingrange
    {
    ESDID esdid;
    int start;
    int end;

    bool operator<(const usingrange& other) const
    {
    return esdid < other.esdid && start < other.start &&
    end < other.end;
    }
    }

    I've used && and < because you do not want operator<() to return true for two different objects when you swap them around.

    C / C++ / MFC c++

  • Invalid comparator for STL map
    G Graham Breach

    Does your ESDID class have an operator<() function? If not, add one.

    C / C++ / MFC c++

  • TSQL - JOIN cancels out my date filter
    G Graham Breach

    You have an OR in there without any parentheses, that might be the problem. Try this:

    AND (project.status = 'construction' OR project.status = 'finished')

    Both sides of the OR are using the same table column, so you could use IN instead

    AND project.status IN ('construction', 'finished')

    Database sales php database sql-server testing

  • TSQL - Create a JOIN, knowing that it may not exist, but show the initial records at least instead of nothing [bad idea] - abandoned it
    G Graham Breach

    Not sure if this is quite what you are looking for, but here goes:

    SELECT
    vendor.Vendor_ID,
    vendor.Company_Name,
    vendor.DELETE_FLAG,
    proj_cost.cost,
    proj_cost.pref_vendor
    FROM vendor
    LEFT OUTER JOIN proj_cost ON proj_cost.Vend_ID = vendor.Vendor_ID
    WHERE (proj_cost.proj_id = '4077'
    AND proj_cost.proj_stage = 'construction'
    AND proj_cost.vers_id = '8'
    AND proj_cost.task_Oper = '6'
    AND proj_cost.vend_id = '54'
    AND proj_cost.task_id = 'TK_EX_044')
    -- vendor without matching proj_cost
    OR proj_cost.Vend_ID IS NULL

    Database sql-server com business json help

  • MFC. How to display a bitmap or a .png file
    G Graham Breach

    Restoring the old bitmap should happen on the MemDCLady DC where you called the first SelectObject(), not the one passed in as pDC.

    C / C++ / MFC graphics c++ performance tutorial learning

  • Style question
    G Graham Breach

    If the function modified the contents of the container I would probably pass it the container reference, otherwise I would prefer the iterators (or even a std::span).

    C / C++ / MFC question c++ docker tutorial

  • List assertation failure
    G Graham Breach

    Instead of trying to manipulate the contents of these structs from outside I would add member functions to do it.

    C / C++ / MFC

  • List assertation failure
    G Graham Breach

    It means that your "tcbcollecter" list was empty when you assigned the "tcbitrate" iterator. Calling begin() on an empty list will give you the end() iterator, because there is no real element to point to. You can't dereference it because it doesn't point at anything.

    C / C++ / MFC

  • Help with STL list::insert
    G Graham Breach

    When you want to traverse the list get an iterator with begin(). This is the first element in the list. Access the information you need, then increment the iterator. If it is equal to end() then you have reached (one item past) the end of the list:

    for(auto i = my_list.begin(); i != my_list.end(); ++i)
    {
    // do something with iterator i
    std::cout << "Item " << i->name << "\n";
    }

    Or you could use range-based for:

    for(auto& i : my_list)
    {
    // do something with i, which is a reference to the item in the list
    std::cout << "Item " << i.name << "\n";
    }

    ATL / WTL / STL c++ help question

  • Help with STL list::insert
    G Graham Breach

    If you want the first element of a list you can use list.front() and for the last element list.back(). The push_front() function adds elements at the start of the list and push_back() adds them at the end. The list doesn't start off with any fixed length, it grows and shrinks as you add and remove elements. So if I was adding two items to a list I would do something like this:

    ItemType item1, item2;
    std::list my_list;

    my_list.push_back(item1);
    my_list.push_back(item2);

    You should use insert() when you want to add an item in the middle of the list - the iterator you pass in should point to the element you want to insert the new item in front of.

    ATL / WTL / STL c++ help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups