View Single Post
Old 12 August 2017, 14:09   #9
chocsplease
Registered User

 
Join Date: Dec 2016
Location: london
Posts: 157
Quote:
Originally Posted by mark_k View Post
How about using fprintf() instead of sprintf()?

It's kind of a hack, but can you open NIL: then call fprintf() outputting to NIL: to discard the output since you're just interested in the return value?
Many thanks for the suggestion, it may be a hack(ish) but it works. the only problem I have is that the resulting executable is 7.7K for something that is tiny. So I tried to 'Amigaise' it - this is my code.

Code:
#include <proto/dos.h>
#include <proto/exec.h>
#include <ctype.h>
int main()
{
    BPTR *fh;
    long result;
    int number =57;
    fh = Open("NIL:", MODE_NEWFILE);
    if (fh) /*if file opened*/
    {
        result=VFPrintf(fh,"This is a test %ld",(long)number);
        Close(fh);
    }

    Printf("the result is %ld\n",result);
}
I have a problem
  • I am getting a warning on the VFPrintf line (Initialisation makes integer for a pointer without a cast)
The executable is 2.2 k and it works, but I've had problems finding info on VFPrintf so suspect I've got the args wrong, can someone point out where?


Many thanks.

Last edited by chocsplease; 12 August 2017 at 14:17.
chocsplease is offline  
 
Page generated in 0.08619 seconds with 10 queries