strtok function


I am using strtok and my code works. My teacher is really big on functions. I am trying to call the function inside of main to a separate function outside of main. However, because strtok is a predefined function i cant figure out how to call the function.
I am doing this to keep my program cleaner bc the teach likes it that way.

1
2
3
4
5
6
7
8
9
10
11
12
  p = strtok ( str, " ,;.?!" );   /* look for any of these in target */
  if ( p ) {
    cout << "\nThe tokens are ";
    cout << "<" << p << ">";
    do {
      /* use null ptr for remaining calls */
      p = strtok ( NULL, " ,;.?!\n\t" );
      if ( p )
        cout << "<" << p << ">";  /* if not null print token */
      } while ( p );
    }


I need to know how to call the function. I dont understand how to make a function declaration, function call, and function heading?
Thanks
closed account (Dy7SLyTq)
a) i think you need to derefence the pointer (ie *p) when printing it and using it as a condition

b) http://www.cplusplus.com/doc/tutorial/functions/
Topic archived. No new replies allowed.