I just have a question about %f


#1

I was wondering… it seems that I have to remember what order I add the variables at the end of my printf statement to make sure I have them listed in the order I want them.

Is there an easier way to do this?

Or I should say, is there a way I can specify where I want to display a variable inside the quotes without trying to remember what order I list the variable names at the end of the line?

What if I just wanted to display 100 variables to the user? Would I really have to type %f 100 times and then list 100 variable names at the end?

Thanks,
Doug


#2

[quote=“Douglas”]

What if I just wanted to display 100 variables to the user? Would I really have to type %f 100 times and then list 100 variable names at the end?

Thanks,
Doug[/quote]

I’m new to this (Chpt 5 :wink:) but I recon you’d use a loop - Chpt 7.


#3

I don’t think a loop would work if the variables are all different.

I was just wondering if there was a different way to using %f in a printf statement. Right now, as of this chapter, I know what the variables are because I am entering them in the code, so it’s fairly easy to just name them off at the end of the line. But what if I don’t know what the variables are? Or what if I don’t know how many variables there are?

Thanks for replying Calcien. I appreciate your response. Seems this forum isn’t as popular as I’d hoped it would be. :frowning:


#4

[quote=“Douglas”]I was wondering… it seems that I have to remember what order I add the variables at the end of my printf statement to make sure I have them listed in the order I want them.

Is there an easier way to do this?

Or I should say, is there a way I can specify where I want to display a variable inside the quotes without trying to remember what order I list the variable names at the end of the line?

What if I just wanted to display 100 variables to the user? Would I really have to type %f 100 times and then list 100 variable names at the end?

Thanks,
Doug[/quote]

Hi Doug, I find the forum helpful, it just seems people might not be so involved in the forum in the earlier chapters. I believe that we have to use the %f as this tells the computer what information needs to be passed in that location. I’m not sure if there is another way of doing, I have a feeling this is the way of doing it. My guess to your question about the 100 variables is that you can maybe create some kind of function that will allow you to do this. Again this is a guess.


#5

I’d agree…I’m getting into this book and it’s my 3rd time reading it just so that I can grasp coding in C and Objective-C. I have to build an app soon :arrow_right: