Calculating highs, lows, and volumes of stocks I'm trying to review and figure the issues in the above code. Any inputs to point out problems are welcome.

using namespace std;
typedef basic_string&lt;char&gt; string;

class   CHighLow
{
public:
    CHighLow() : nCurLow(0), nCurHigh(0) {};

    void    add(int nHigh, int nLow)
    {
        if (nHigh &gt; nCurHigh)
            nCurHigh = nHigh;

        if (nLow &lt; nCurLow)
            nCurLow = nLow;
    }

    int     nCurLow;
    int     nCurHigh;
};

int main(int argc, char* argv[])
{
    if (!strcmp("version", argv[1]))
    {
        cerr &lt;&lt; "Using version 1.0 VWAPer" &lt;&lt; endl;
        return 0;
    }

    FILE*   file = fopen(argv[2], "r");

    cerr &lt;&lt; "Reading file" &lt;&lt; argv[2] &lt;&lt; endl;

    char    line[256];
    char    Stocks[1000][10];
    int     Intervals[1000];
    int     Volumes[1000];
    float   Highs[1000];
    float   Lows[1000];

    int     i = 0;
    int     sum = 0;

    while (fgets(line, 256, file))
    {
        sscanf(line, "%s %d %d %f %f", 
Stocks[i], &amp;Intervals[i], 
&amp;Volumes[i], &amp;Highs[i], &amp;Lows[i++]);

        cerr &lt;&lt; Stocks[i] &lt;&lt; endl;
        cerr &lt;&lt; Intervals[i] &lt;&lt; endl;
        cerr &lt;&lt; Volumes[i] &lt;&lt; endl;
        cerr &lt;&lt; Highs[i] &lt;&lt; endl;
        cerr &lt;&lt; Lows[i] &lt;&lt; endl;
    }

    cerr &lt;&lt; "Calculating total volumes" &lt;&lt; endl;

    map&lt;std::string, int&gt;       TotalVolumes;

    for (int s = 0; s &lt;= i; ++s)
    {
        std::string stockname = Stocks[s];

        for (int j =0; j &lt;= i; ++j)
        {
            if (!strcmp(Stocks[j], stockname.c_str()))
            {
                TotalVolumes[stockname] += Volumes[j];
            }
        }
    }

    cerr &lt;&lt; "Calculating high lows" &lt;&lt; endl;

    map&lt;std::string, CHighLow&gt;  HighLows;

    for (int s = 0; s &lt;= i; ++s)
    {
        HighLows[Stocks[s]].add(Highs[s], Lows[s]);
    }

    cerr &lt;&lt; "Writing files" &lt;&lt; endl;

    // write file a
    for (int s = 0; s &lt;= i; ++s)
    {
        cout &lt;&lt; Stocks[s] &lt;&lt; "," &lt;&lt; Intervals[s] &lt;&lt; "," &lt;&lt; 
TotalVolumes[Stocks[s]] / Volumes[s] * 100 &lt;&lt; endl;
    }

    // write file b
    map&lt;std::string, CHighLow&gt;::iterator itr = HighLows.begin();
    while (itr != HighLows.end())
    {
        cout &lt;&lt; (*itr).first &lt;&lt; "," &lt;&lt; (*itr).second.nCurLow &lt;&lt; "," &lt;&lt; 
(*itr).second.nCurHigh &lt;&lt; endl;

        ++itr;
    }

    return 1;
}
First, the obvious ones:


Change nCurLow and nCurHigh to floats since you are reading float from file.
Change

nCurLow(0)


to

nCurLow(std::numeric_limits&lt;float&gt;::infinity())


and

nCurHigh(0)


to

nCurHigh(-std::numeric_limits&lt;float&gt;::infinity())


because initializing min/max with 0 can lead to bugs if values are all >0 or &lt;0.
Drop typedef basic_string&lt;char&gt; string; and use std::string instead.
Check argc if you have arguments before you use argv (prevents crash when invalid arguments are passed).
Don't use cerr only when you want to report error, use std::cout instead.
Don't increment i like this: ... &amp;Lows[i++]);. In fact drop those arrays all together and use std::vector, and std::string instead (because that while so broken in so many ways ...).
The iteration looks bogus, for (int s = 0; s &lt;= i; ++s) because of &lt;= so change it to ranged-based fors.
Avoid stdcmp; use operator== from std::string.


These points only refer to potential errors and bugs.

Now for the less obvious ones:


I see a comment //write to a file. std::cout does not write to file but to standard output. use file streams if writing to a file is the intended behavior
This code:

for (int s = 0; s &lt;= i; ++s)
{
    std::string stockname = Stocks[s];

    for (int j =0; j &lt;= i; ++j)
    {
        if (!strcmp(Stocks[j], stockname.c_str()))
        {
            TotalVolumes[stockname] += Volumes[j];
        }
    }
}


What does it actually do? It looks totally inefficient. The obvious thing is that TotalVolumes[stockname] can be evaluated only once. The second is that j can be equal to s. 
The rest of the code seems to make excessive use of memory. It looks like it can be simplified a lot, with fewer iterations, less memory usage, less confusion. 
It would be nice if there would be some comments to describe what the code actually does.
return 1 in main. If this will be used in an automated tool return 1 might mean that an error has occurred. Change it to return 0 and return 1 only when an actual error has happened (invalid argument, file not found, corrupted file data, etc).
More error checking.


There could be other things, but having some test data would be nice. There could be soft bugs in the code.