-
March 22nd, 2009, 08:31 AM
#1
[RESOLVED] finding the offset in a char array
i have an array of char that looks like this:
"This_is_my_example_string"
im splitting the string on every "_" character , but also i want to find the position After the last "_" character and store it on an integer variable
how can i do that?
Code:
Splits = strtok( cBuffer, "_" );
while( Splits != NULL )
{
Splits = strtok( NULL, "_" );
}
-
March 22nd, 2009, 08:54 AM
#2
Re: finding the offset in a char array
If the return value of strtok() is not NULL, then subtract the return value of strtok from the address of the buffer you're searching.
Edit:
Sorry, that should be subtract the starting address of the buffer from the return value of strtok.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; March 22nd, 2009 at 01:11 PM.
Reason: Clarification:
-
March 22nd, 2009, 10:14 AM
#3
Re: finding the offset in a char array
thanks for the idea
-
March 22nd, 2009, 01:12 PM
#4
Re: finding the offset in a char array
Originally Posted by Cpp_Noob
thanks for the idea
Before doing anything, see the edit to my post.
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|