CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2014

    [RESOLVED] char myTree[350000] Bad practice?

    Hi, I'm working on a piece of code written long time ago. Without getting in the details or too much context here, there is a function that declares an array of char of a size of 350,000 elements, in order to fill it (using a pointer) with the list of all running processes on the machine (using "ps -ejf" on a Linux box).

    The size of the char array has been changed from 40,000 to 350,000 sometime along the years, probably because of a lack of space required.

    What kind on data structure / storage would you use to store the running processes in order to eventually search for a value in it?


  2. #2
    Join Date
    Feb 2003
    Iasi - Romania

    Re: char myTree[350000] Bad practice?

    To keep a list of only process names, one can be std::list<std::string>.
    To keep more info for each process, you can define a structure, then make a list having elements of that structure (e.g. std::list<PROCESS_INFO>)
    Last edited by ovidiucucu; June 5th, 2014 at 10:57 AM.
    "When in Rome, do as Romans do."
    My latest articles:

  3. #3
    Join Date
    Apr 2000
    Belgium (Europe)

    Re: char myTree[350000] Bad practice?

    rewrite the code to not require a fixed array.

    properly parse the output of the command and store it in a C++ container (pick whichever one suits best).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width