Thread: Basic and GENERAL strtok question

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    84

    Basic and GENERAL strtok question

    In strtok, if using in ala
    Code:
    char token = ",";
    
    // code here //
    
    str = strtok(line, token);
    if line doesn't contain any tokens but is a string, would it return a base address/position?
    Then if used again, would return a NULL?

    This seems to be the case in some code im looking at, this correct?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Here, 'token' is just a single character, not a string. Anyway, from the man page:
    The strtok() and strtok_r() functions return a pointer to the beginning
    of each subsequent token in the string, after replacing the token itself
    with a NUL character. When no more tokens remain, a null pointer is
    returned.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    84
    ? So what your saying is...

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    If line does not contain token, NULL is returned.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. general question
    By a.mlw.walker in forum C Programming
    Replies: 25
    Last Post: 04-04-2009, 09:32 AM
  2. Newbie Question - fflush(stdin) & fpurge(stdin) on Mac and PC
    By tvsinesperanto in forum C Programming
    Replies: 34
    Last Post: 03-11-2006, 12:13 PM
  3. Very basic question
    By something___ in forum C Programming
    Replies: 13
    Last Post: 12-08-2004, 02:53 PM
  4. Visual Basic Question
    By Xeavor in forum Tech Board
    Replies: 5
    Last Post: 12-02-2004, 09:59 AM
  5. General question about C++ Programming/Computer Science
    By learning C++ in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-05-2004, 10:18 PM