I'm going to try converting some PHP code into C++ that I wrote (a tokenizer). I think I'm going to need an array that contains a fixed number of elements, each of which is a very simple structure. Maybe I need a linked list instead but I haven't quite worked that out yet
OK I know how to initialize an array of say, integers with a list of values:
Code: Select all
int foo[] = { 1, 2, 3 };Code: Select all
#include <iostream>
using namespace std;
//A pattern and a 1 or a 0
// depending upon if the
// pattern is a regex
struct tokDef
{
char *pattern;
char *tokName;
int re;
};
//The array we'll store our defintions in
tokDef defintions[] = {
/** How can I add some values here? **/
};
int main()
{
//
return 0;
}The array hold defintions for a load of tokens that in PHP I was doing with a multi-dimensional array like this:
Code: Select all
$tokenDefs = array(
'TOKEN_ONE' => array('/\bfoo\d{2}/', 1),
'TOKEN_TWO' => array('::', 0)
);Cheers if anyone can push me in the right direction