wrighting a printf stament

Posted by Proto-6 on Fri 14 Mar 2003 09:50 PM — 5 posts, 17,570 views.

Canada #0
ok i've been trying to install a a printf statment sot get a %LF to worke and what im wundering is that do I need to put it in a spacifick area or can it fit any where in the code just floting in some random string

allso could I get a exampol of what one would look like I dont need a real on a fake one would do I just want to compar it too mine to see if I did it right or not

thanx :]

P.S. I have never writen one in my life so this is verry new to me I hope this isent too stuped of a question
Amended on Fri 14 Mar 2003 10:25 PM by Proto-6
Australia Forum Administrator #1
It is hard to give an example without knowing what you are trying to do. Perhaps post what you have done, and we can comment.

First, it is printf, not printif as you had in your post.
Canada #2
ooo ya sory i'v been working on not dooing that :) I hate making spelling mistakes any whay her is the printf statment I have

int sprintf(buf, "%lf", long double);

i just whant it to be abil to show long double's
allso as I sead dose it matter where it is put in the code or can it be on any lign I want it to be on
Australia Forum Administrator #3
It is hard to know where to start here. I suggest trying to learn C using a simpler program than a MUD server.

Major changes are required, something like this:


char buf [100];
double mynumber = 22.5;

sprintf (buf, "%f", mynumber);


Quote:

do I need to put it in a spacifick area or can it fit any where in the code just floting in some random string


The nature of programming is such that the order of things is important. You put the line in the part of the code where you want the number to be converted to a string.
Amended on Sat 15 Mar 2003 04:53 AM by Nick Gammon
Canada #4
hay thanx this will help alot and I agree unfortunitly I have a one track minde and once I start somthing I cant stop ( I dident want to do the mud thing first my mom convinced me to and then I went all gung ho) but Ill try to do a simpole program if I get time and ill allso look for a good book on c but now I know that I cant just put the code any where so thanx :)