MinGW The Merciful

A special thanks goes out to my fellow GNU users who need want to program under MS Windows. Eventhough they don’t provide a random function MinGW is definately a must for those wishing to create good native software under MS Windows. For those who want to preserve there voice anyway. I will try to share some lessons learned as I fully figure out how to get things working right. Here is a little nugget in the mean time since MS does not provide strtok_r


char *c_strtok_r( char *str, char *delim, char **save_ptr ) {
  char *ptr;

  if( !str ) {
    if( !*save_ptr || !**save_ptr )
      return( NULL );
    str = *save_ptr;
  }

  while( *str && strchr( delim, *str ) )
    ++str;

  if( !*str )
    return( NULL );

  ptr = str;

  while( *ptr && !strchr( delim, *ptr ) )
    ++ptr;

  *save_ptr = *ptr ? ptr + 1 : ptr;
  *ptr = '\0';

  return( str );
}

  • Computer Science
  • Linux and Systems
. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply


Bad Behavior has blocked 149 access attempts in the last 7 days.