Thread: Function call

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    1

    Question Function call

    What do'es the strok() do?

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    never heard of it.....

    did u mean strtok() ??
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    A strtok example
    Code:
    #include <stdio.h>
    #include <string.h>
    
    int main ( ) {
      /* a string, which must be in writable memory */
      char msg[] = "sia john kim dave kelly earth moon door room";
      char delim[] = " ";  /* the delimiters - just a space in this case */
      char *token;
      int count = 0;
      for ( token = strtok(msg,delim) ; token ; token = strtok(NULL,delim) ) {
        count++;
        printf("C=%d, T=`%s'\n", count, token );
      }
      return 0;
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM