• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

Windows and Unix compatibility


One of my application in unix , i have used isblank("") and strcasecmp() functions .
but in windows , they are not working . Anybody knows what are the equvalent functions
in windows.

Thanks in advance
1 Solution
dont know windows equivalent but you can code them yourself

int isblank ( char * in )
        if ( *in == ' ' || *in == '\t' || *in == '\n' )
                   return 1;
                   return 0;

likewise, in the implementation of if toupper/tolower are available on windows, you can convert both strings to the same case and then use strcmp()
you've got:

_stricmp for strcasecmp
expertyasinAuthor Commented:
Hi guys,

Both answers are useful to me .

Hi yahelb ,

  Can I use this stricmp() function in unix also . Is it compatible with Unix or i need to identify the OS and based on the code those two functions ?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

>Can I use this stricmp() function in unix also .
No. All the functions with name started with '_' are Microsoft specific.

There is no ANSI equivalent for stricmp as far as I know.
Kent OlsenData Warehouse Architect / DBACommented:

Hi expertyasin,

All if the isxxxxx() macros are defined in ctype.h.  Include that header file and isblank() will work just fine.

strcasecmp() appears to be a proprietary API.  If the purpose of the function is to compare two strings without regard to case ("STRing1" will match "string1") then use the strncmp() function.  strncmp() is portable and should be supported on all platforms.

Good Luck,
when writing portable code you'll have to some odd hacks such as:

#ifdef __linux__
#include <unistd.h>
#end if

#ifdef WIN32
#define strcasecmp stricmp

#ifdef OTHER_OS
#define strcasecmp my_strcasecmp
#include "my_strcasecmp.h"

so in your code you just write once

strcasecmp(string1, string2);
Kent OlsenData Warehouse Architect / DBACommented:

stricmp() is the "case insensitive" string compare used by Micro$oft and Borland.  strncmp() is the equivalent in unix/linux.

I know that Borland supports both stricmp() and strncmp() but I don't know about MS.

Since your original question was unix related, change all occurrences of "strcasecmp" to "strncmp" and you'll be fine.

Or take the approach suggested by g0rath and define an equivalence:

#define strcasecmp strncmp

The second suggestion is the "quick and dirty" way to get past the error, but it works just fine.  You might as well get used to typing strncmp() so please seriously consider changing "strcasecmp" to "strncmp".

uh according to the man page....unix side

// Both case insenstive, but one you specify the first N bytes
int  strncasecmp(const  char  * s1,  const  char  * s2,  size_t  n);
int  strcasecmp(const  char  * s1,  const  char  * s2);

// Both Lexical, but one you specify the first N bytes
int  strncmp(const  char  * s1,  const  char  * s2,  size_t  n);
int  strcmp(const  char  * s1,  const  char  * s2);

strcasecmp != strncmp under unix
but windows changes things to be not quite as compatible


Perform a lowercase comparison of strings
int _stricmp( const char *string1, const char *string2 );

Compare characters of two strings without regard to case.
int _strnicmp( const char *string1, const char *string2, size_t count );

Lexical comparison
int strncmp( const char *string1, const char *string2, size_t count );

strcasecmp(unix) != strncmp(msvc++) ... now that my be true about Borland...but just be aware when comparing
Kent OlsenData Warehouse Architect / DBACommented:

Man.... where was head?  I meant stricmp() and strcmpi()....



Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now