Find the total volume traded for each stock and also find the high and low for each of those stocks I would like to know whether the following code can be changed in any way as to improve its functionality. Could there be any potential bugs that may arise as a result of how the code is written?

The program is designed to find the total volume traded for each stock
and to also find the high and low for each of those stocks.

Are there any lines of code that are poorly written?  Either syntactical or just a better way to express the logic.

#include &lt;cstdio&gt;
#include &lt;cstring&gt;
#include &lt;map&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;


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&amp; getSum()
    {
        int sum = nCurLow + nCurHigh;
        return sum;
    }

    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; "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]);
        cout &lt;&lt; HighLows[Stocks[s]].getSum();
    }

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

    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;
    }

    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;
}
I see a number of things that could help you improve your code.

Don't abuse using namespace std

Putting using namespace std within your program is generally a bad habit that you'd do well to avoid.  

Don't redefine standard names

This definition is a problem:

typedef basic_string&lt;char&gt; string;


It redefines std::string (because you've used the global namespace).  Better would be to simply use std::string without redefining it.

C++ is case sensitive

Your code includes a line:

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


There is no Map, but there is std::map.  Write the line like this instead:

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


Don't rely on unspecified execution order

The code currently contains this:

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


The problem is that it appears you're assuming that i is incremented after the sscanf completes, but that's not guaranteed by the standard and the code is ambiguous.  Instead, write it like this:

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


Use const where possible

The CHighLow::getSum function does not (and should not) alter the underlying data structure and should therefore be declared const.

Don't return a reference to a local variable

The CHighLow::getSum() function is written as returning a reference to an int.  In addition to this being somewhat unusual, in this case, it's also incorrect.  The reason is that it's returning a reference to sum which is a local variable within the function.  When the function returns the variable goes out of scope and is destroyed, so the reference is now pointing to unallocated memory.  That's a serious bug!  Instead, just return an int as in:

int getSum() const
{
        return nCurLow + nCurHigh;
}


Eliminate unused variables

Unused variables are a sign of poor code quality, so eliminating them should be a priority.  In this code, sum is set to 0 within main() but then never actually used.  My compiler also tells me that.  Your compiler is probably also smart enough to tell you that, if you ask it to do so. 

Check array length before dereferencing

If the user fails to give the program command line arguments, this line will fail:

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


It would fail because there might might not be any argv[2] so you should check the argc value first and exit with an error, perhaps telling the user what the program requires, if there aren't enough arguments.

Make member data private

The the two data members of the CHighLow class are public so any function or code can alter their contents.  This is not generally good design.  Instead, make them private.  Because the only instance their needed is for output, that can be neatly solved with the next suggestion.

Write a custom stream inserter for a class

The code currently contains this:

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

        ++itr;
}


There are a number of things that could be improved here.  First, use a "range-for" and second, use a custom stream inserter.  That results in this code:

for (const auto &amp;stock: HighLows) {
    std::cout &lt;&lt; stock.first &lt;&lt; "," &lt;&lt; stock.second &lt;&lt; '\n';
}


Then in the class, create a custom inserter:

friend std::ostream&amp; operator&lt;&lt;(std::ostream &amp;out, const CHighLow &amp;hilo) {
    return out &lt;&lt; hilo.nCurLow &lt;&lt; "," &lt;&lt; hilo.nCurHigh;
}


Use C++ file I/O

Don't use the ancient FILE* I/O but instead use modern C++ std::fstream.  The interface is neater and you can write a nice class extractor instead of having all of the details for extracting data placed within main.

Don't use std::endl if '\n' will do

Using std::endl emits a \n and flushes the stream.  Unless you really need the stream flushed, you can improve the performance of the code by simply emitting '\n' instead of using the potentially more computationally costly std::endl.

Don't return nonzero from main unless there's an error

The convention in programming in C and C++ is that the returned integer from main() is considered by the operating system to be construed as an error code.  For that reason, the non-error condition is signalled by returning a 0.  Your code ends with return 1 which will be interpreted by most operating systems as an indication that an error was encountered.  Because the compiler will automatically generate the equivalent of a return 0; at the end of main(), I'd advocate simply omitting it.