CompuServe Thread

#Variable Printing in 'C'

9 messages in this thread
#14865From: tim parkerOct 4, 1991 11:11 AM
Hello All! I am looking to try and find out how to print/append variables to the end of my text strings (Intuitext). I can get all the text to print but need to add some changing variables to the end…Can't seem to figure it out with all my books so all you 'C' programmers HELP! 🙂 Thanks tim
#14873From: Vic WagnerOct 4, 1991 3:03 PM
Tim, PrintIText() _only_ prints "text". There IS no formatting. You must format your "variables" first and put them into a string. Probably the simplest is to use sprintf() to do it.
#14880From: tim parkerOct 4, 1991 9:02 PM
Ok I may be lost in this one and will have to hit the books, but the jist of what I want to do is….I am working on a baseball game with stats and such and need to have something like: Strikes: 0 where the zero would be the variable and would be say sr and would or could change with each pitch and would reprint each time how could I have it changed to a string and then print it beside or in line with the word strike? Tim
#15112From: Larry SchillingOct 8, 1991 7:17 PM
try: printf("Strikes: %1d",sr); Note that there is no '\n' to advance the line, so the next print will print in exactly the same place. If you ever have (by mistake, of course) more than 9 strikes, the above will fail 🙂 Larry Schilling
#15156From: tim parkerOct 9, 1991 7:14 AM
Ok Don't mean to come off wrong but I believe in my original message it said that I am working with an Intuitext STructure for printing in a custom window…so this will not work…any other ideas, pleaseeeeee! 🙂 tim
#15182From: Steve AhlstromOct 9, 1991 12:18 PM
I don't understand the problem. sprintf() then point your IntuiText.IText to that array. -sja
#15212From: tim parkerOct 9, 1991 10:30 PM
Ya know Steve…I think you're right I don't understand the problem either?! 🙂 That works for me….I am still wading my way through all these books and figured it had to be something simple! Thanks for the push in the right direction! Tim
#15220From: Steve AhlstromOct 9, 1991 11:46 PM
Tim, If you can structure your code a bit differently, there is a faster way to achieve the same thing. sprintf() then use Move()/Text().
#15267From: tim parkerOct 10, 1991 11:39 AM
I will look into that….(Move()/TExt()) and see what it looks like…Thanks for the input and I will talk to ya soon…. Tim