Feb 26, 2014 at 2:21pm UTC
I have a problem, so you can explain me what the "context" in this source_code
This is Stebe jobs's code:
#include <iostream>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
string CleanLine(const string& n)
{
string cleanline;
char* char_line = (char*)n.c_str(); // Non-const cast required.
char* token = NULL;
char* context = NULL;
char delims[] = " ,\t\n";
// During the first read, establish the char string and get the first token.
token = strtok_s(char_line, delims, &context); //THIS
// While there are any tokens left in "char_line"...
while (token != NULL)
{
// Accumulate the tokens.
cleanline += token;
cleanline += ' ';
// NOTE: NULL, function just re-uses the context after the first read.
token = strtok_s(NULL, delims, &context); and THIS
}
return cleanline;
}
Thank you very much!
Last edited on Feb 26, 2014 at 2:23pm UTC
Feb 26, 2014 at 2:37pm UTC
Last edited on Feb 26, 2014 at 2:41pm UTC
Feb 26, 2014 at 2:58pm UTC
Last edited on Feb 26, 2014 at 2:58pm UTC
Feb 26, 2014 at 3:11pm UTC
I understand.
Thank you very much KBW!