[Ilugc] strtok
- From: kumanna@xxxxxxxxxxxxx (Adayapalam Appaiah Kumaraswamy)
- Date: Tue Jul 20 13:50:01 2004
Viveka Nathan K wrote:
Hi..
By using strtok(), if I read the /etc/passwd file with delimiter ":",
I am not getting expected result. For example, if a line contains
rpm:x:37:37::/var/lib/rpm:/bin/bash
the '::' is read at once instead of twice.
Is there any other way to read data with delimiter ?
Thanks,
I worked around this, using a dirty trick!
I used strdup to create an exact copy of this string (say x) to x2.
Then, call strtok with x. Now, whenever you get a token, the separator
would be x2[token - x - 1].
Please tell me if that worked.
Kumar
--
Adayapalam Appaiah Kumaraswamy
(Kumar Appaiah)
1, Balaji Apartments,
32, Third Street,
East Abhiramapuram,
Mylapore, Chennai - 600004
Other related posts: