Eric Auer wrote: > > Hi Franta, > >> I got the impression that string declared as >> >> char mystring[]="$DOSEMU$"; >> >> is in memory stored as null-terminated string. > > This does not help you: The OTHER string STARTS > with "$DOSEMU$", but is NOT null terminated, so > both strings still differ. Unless you explicitly > say you only want to compare the first 8 bytes. > In short, you still have to use strncmp() here.
My mistake was that I assumed that the comparison end by reaching end of the shorter string - then my code should work right. But now I finally read the strcmp() man page (Linux man pages v3.51), and there is stated: #include <string.h> int strcmp(const char *s1, const char *s2); The strcmp() function compares the two strings s1 and s2. It returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2. RETURN VALUE The strcmp() functions return an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2. from which it seems as specify null-terminated string as first argument should be sufficient for not comparing more bytes than its length. But in my Linux system is also strcmp() man page from POSIX Programmer's Manual, and there isn't stated this (even there says that 'Linux implementation of this interface may differ...') Thus, as You says, perhaps isn't possible rely on this strcmp() behavior and it is necessary to use strncmp(). Eric and Ralf, thanks for your advices. Franta Hanzlik ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Freedos-user mailing list Freedos-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-user