i am using strtok function to break the string into desirable parts.
i am using the following code :
const char seps[6] = "\n\t";
char *token;
token = strtok( a, seps );
char *arr[5]={NULL};
arr[i]=token; string buf= arr[3];
However whenever i break my tokens, for some tokens for the description field, an extra character is appended to random rows.
For e.g.
Dear parents is shown as Dear parentsuè
Out of 4 lines these extra character appends to say the description tokens of last 2 lines or so. This thing does not happens with nay of other tokens.
Can you suggest me something which i may be overlooking or missing?
while( getline( myTfile, s1 ) )
{
char * a = new char[s1.size() + 1];
std::copy(s1.begin(), s1.end(), a);
const char toks[6] = "\n\t";
char *token;
token=NULL;
token = strtok(a,toks);
char *arr[5]={NULL}; int i=0;
while( token != NULL )
{
arr[i]=token;
i++;
token++;
token = strtok(NULL,toks);
}
string buf= arr[3]; }
Input is some thing like :
+ 123123123 243.20 textstring1
- 123454355 123.10 textstring2
Now for textstring2 or some random string in the lie input, an extra character is appended to random rows.
For e.g.
Dear parents is shown as Dear parentsuè