i want to strtok a string from flat file which consist of 3 part..(eg. N XXX98 34-XXX)
howto assign each part into a variable so i can memcpy the last part into a variable? i do not want to use printf which print out the output to screen.
string is from the file
string2 is a char * declared in the code
x = strlen (string);
int z = 0;
for (int y = 0; y < x; y++)
{
if (Z == 2)
{
for (z = 0; y < x; y++)
{
string2 [z] = string [x];
z++;
}
string2 [z] = NULL;
}
else if (string [y] == ' ')
z++;
}
this may need tweaking but its the method I'd
use to get the last parameter in the string gotten
from the file. you can modify it to get each parameter.
You could also make use of the [tt]strrchr[/tt] function. Something like this:
[tt]char *last;
last = strrchr(string, " "
last += sizeof(char);[/tt] //Daniel
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.