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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
V

Vaclav Naydenov

@Vaclav Naydenov
About
Posts
2
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • C code : read infomation of USB
    V Vaclav Naydenov

    Take a look at libusb Windows port: https://sourceforge.net/projects/libusb-win32/[^] or the original libusb https://sourceforge.net/projects/libusb/[^] The library allows for communication with an USB device from an user-space application. No kernel programming required.

    C / C++ / MFC question

  • How to constructor a storage class to store Tree data in C++
    V Vaclav Naydenov

    You can use a struct or a class with nested vector of same type structs:

    #include <vector>
    #include <string>
    #include <iostream>

    struct TreeNode {
    std::string payload;
    std::vector<TreeNode> children;
    TreeNode(const std::string &p): payload(p) {}
    TreeNode() {} // it's a must if we are to store nodes in a vector
    };

    void walk_tree(TreeNode &node, int indent = 0) {
    std::cout << std::string(indent * 4, ' ')
    << node.payload << std::endl;
    for (size_t i = 0; i < node.children.size(); ++i)
    walk_tree(node.children[i], indent + 1);
    }

    int main() {
    TreeNode a("home");
    a.children.push_back(TreeNode("peter"));
    a.children.push_back(TreeNode("jane"));
    a.children[0].children.push_back(TreeNode("game.exe"));
    a.children[1].children.push_back(TreeNode("homework.txt"));
    walk_tree(a);
    return 0;
    }

    C / C++ / MFC tutorial c++ data-structures
  • Login

  • Don't have an account? Register

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