What the code does: accept a stock ticker eg AAPL as text input. It assigns it a number if it hasn't already been assigned a number. Then returns the number associated with that ticker. Part of a larger program.
The code for int gethandle worked fine when it was in the main program. The main CPP file got too large so this was moved over to a separate .CPP file.
It stops building below the line
int gethandle(string hdlText)
And says
error c2447: '{' missing function header (old style formal list?)
I know this subject has come up before. I browsed through numerous other old threads. Usually the problem was a semicolon where there didn't need to be one. I don't see that anywhere in this program.
#include <iostream>
#include <string>
using namespace std
#include <fstream>
#include <comdef.h> // for _bstr_t
#include <string>
#include "stdAfx.h"
int gethandle(string hdlText)
{ // <<<<-------------------------- This is where the problem is
static string tkr[1000];
static int lastCache;
if (hdlText == tkr[lastCache])
{
return lastCache;
}
int count;
for (count =1 ; count < 1000; count++)
{
if (tkr[count] == hdlText)
{
lastCache = count;
return count;
}
}
for (count =1; count<1000; count++)
{
if (tkr[count] == "")
{
tkr[count] = hdlText;
lastCache = count;
return count;
}
}
return -1000; // debug program elsewhere. We should not run out of handles
}