IDOS->Printf output not the same as printf

This forum is for general developer support questions.
Post Reply
my_pc_is_amiga
Posts: 73
Joined: Sat Dec 08, 2012 7:58 pm

IDOS->Printf output not the same as printf

Post by my_pc_is_amiga »

This is likely a very basic question --- but I'm not getting the same output when I use the IDOS->Printf versus printf. See below. It looks like the pointers are not getting assigned correctly with the DOS function. Is this due to the 64-bit alignment issue?

----------------------------
CONST_STRPTR teststring = "mystring";

IDOS->Printf("%s -%p- -%c- -%p- -%c- end\n",teststring,teststring,*teststring,teststring+1,*(teststring+1));
printf("%s -%p- -%c- -%p- -%c- end\n",teststring,teststring,*teststring,teststring+1,*(teststring+1));

--------------------------

OUTPUT
mystring -0x3e607080- -- -0x006d3e60- -- end
mystring -0x3e607080- -m- -0x3e607081- -y- end
User avatar
colinw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 218
Joined: Mon Aug 15, 2011 10:20 am
Location: Brisbane, QLD. Australia.

Re: IDOS->Printf output not the same as printf

Post by colinw »

All arguments to Printf() are 32 bit minimum width, (VARARGS68K), your format string must specifiy them that way.
ie; %ld instead of %d - %lc instead of %c - etc...

Please review the DOS Printf() / VPrintf() / VFPrintf() autodocs.
my_pc_is_amiga
Posts: 73
Joined: Sat Dec 08, 2012 7:58 pm

Re: IDOS->Printf output not the same as printf

Post by my_pc_is_amiga »

Thanks for the quick response and clarifications!
Post Reply