469,579 Members | 1,195 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

Need Help How to extract tokens and The current index position inside

#include <stdio.h>
#include <string.h>

void string2Lines(char line[], char tokens[]){
char *token_ptr, token[81];
char *i=";" " " "," "." "?" "!";
token_ptr = strtok(line, i );
strcpy(token, token_ptr);
strcat(tokens, strcat(token,"\n"));
token_ptr = strtok(NULL, i );
int main(){
char sentence[81], words[81];
printf("Enter a sentence: ");

How to write a function called findNextToken() that does the same thing as strtok() used above.
It will have three arguments:
(i)The string from which to extract tokens.
(ii)The current index position inside this string at the time of the call. This argument will be sent by reference, since its position will inevitably move past the word that is being extracted.
(iii)The token found, if any. This will return the token the value 1 if a token is found; otherwise it will return 0.
Nov 5 '06 #1
0 1095

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Mad Scientist Jr | last post: by
1 post views Thread by jens Jensen | last post: by
12 posts views Thread by rshepard | last post: by
6 posts views Thread by Hemant Shah | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.