Ralf Quint wrote:
> On 2/9/2015 7:57 PM, Frantisek Hanzlik wrote:
>> Hi Eric,
>> thanks for help,
>>
>> Eric Auer wrote:
>>> Hi Franta,
>>>
>>>>          struct dosemu_detect {
>>>>              char magic[8];
>>>>              unsigned char ver[4];
>>>>          };
>>>>          static struct dosemu_detect far *p = (void far*) 0xF000FFE0;
>>> Note that the way how you create far pointers can differ
>>> between compilers. In particular, with any 32 bit memory
>>> model, things would look quite differently. Just saying.
>> Pointers and things around them are for me still a little
>> incomprehensible ;)
> If you want to program in C, then there is no way around it. For almost 
> everything, and in particular when working with strings, you need to 
> know what you are doing, as the C compiler is doing exactly what you are 
> telling it to do, which in turn might not be what you want it to do...;-)
I want intelligent IDE with voice input... ;)

>>
>>>>          char magicexp[]="$DOSEMU$";          // expected string when on 
>>>> DOSEMU
>>>>
>>>>          if (strcmp(p->magic, magicexp))      // p->magic == "$DOSEMU$" ?
>>> You cannot strcmp this because the string is no C style
>>> string with a NUL character at the end. You could use
>>> strncmp(string1, string2, 8) to compare only the first
>>> eight bytes, which will probably work fine for you :-)
>> But 'magicexp' is null-terminated string, yes?
> No.
Are You sure? From what I've seen at several web articles (e.g. here
http://www.tutorialspoint.com/cprogramming/c_strings.htm
https://www.youtube.com/watch?v=Zy2bNkSxv8M
), I got the impression that string declared as

char mystring[]="$DOSEMU$";

is in memory stored as null-terminated string.

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

Reply via email to