im writing a program and C using MS Visual Studio 2005 Pro Ed.
i have this function protoype which i have under "routines.h" as:
int tokenize(char *token[ ], int max_tokens, char *str);
and i have the actual function in "routines.cpp" as:
#include "routines.h"
#include %26lt;stdio.h%26gt;
#include %26lt;string.h%26gt;
int tokenize(char token[ ], int max_tokens, char *str)
{
printf("%s\n%s\n\n%s\n",
"The string to be tokenized is:", token,
"The tokens are:" );
str = strtok (token, " ");
while (str != NULL) {
printf("%s\n", str);
str = strtok(NULL, " ");
}
return 0;
}
--------------------------------------...
okay, so how do i call this function from "main.cpp"?
i want to say that its: tokenize(token[ ], max_tokens, str)
but i know its wrong, can anyone help me? im horrible at calling. thanks in advance.
Help with calling this function!?
in main.cpp:
#include "routines.h"
int main (int argc, char **argv)
{
int strLen = 0;
if(argc %26gt;= 2)
{
strLen = strlen(argv[1]);
tokenize(":-/ ", strLen, argv[1]);
}
return 0;
}
Note that you can supply whatever tokens you want in the first argument.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment