Re: how to pass vector<char> as parameter?
I am working on a file parser.
void process_file(std::string filename)
{
//FILE *afile;
char c;
ifstream infile(filename.c_str ());
//if ((afile = fopen (filename, "rt")) == NULL)
//{
// exit(0);
//}
if(!infile)
{
cerr<<"Can't open file " << filename << endl;
exit(-1);
}
//fileData = (char *) malloc (50000);
// memset (fileData, 0, sizeof(fileData));
// fread (fileData, sizeof(char), sizeof(fileData), afile);
while (infile >> c)
{
fileData.push_back(c);
}
printf ("Parsing %s\n", filename.c_str());
parse (fileData, fileData.size());
}
void parse (vector<char> buf, long count)
{
int i,j;
char *tokens[256];
long cnt = 0; // count for number of tokens
char c;
bool ignore = false;
int k = 0;
char buff[256];
PCSTR buf2 = &buf[0];
// char p;
std::string buf3;
// static long token_count = 0;
for (;;) {
memset (buff, 0, 256);
trim (buf2);
is_comment(buf2[0], buf2[1]);
if (one_line_comment)
{
while (*buf2 != '\n') <<<<<<<<<<<< when I took a view at buf2, all \n
disappeared
buf2++;
buf2++; // Skip tail \n