Click here to Skip to main content
16,008,750 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: %1f\n? Pin
DaveE9th7-Jul-03 23:55
DaveE9th7-Jul-03 23:55 
GeneralRe: %1f\n? Pin
Rage8-Jul-03 0:39
professionalRage8-Jul-03 0:39 
GeneralRe: %1f\n? Pin
Ryan Binns8-Jul-03 0:50
Ryan Binns8-Jul-03 0:50 
GeneralRe: %1f\n? Pin
Rage8-Jul-03 1:08
professionalRage8-Jul-03 1:08 
GeneralRe: %1f\n? Pin
Ryan Binns8-Jul-03 1:11
Ryan Binns8-Jul-03 1:11 
GeneralRe: %1f\n? Pin
Rage8-Jul-03 1:12
professionalRage8-Jul-03 1:12 
GeneralRe: %1f\n? Pin
Ryan Binns8-Jul-03 1:14
Ryan Binns8-Jul-03 1:14 
GeneralRe: %1f\n? Pin
Cedric Moonen8-Jul-03 0:50
Cedric Moonen8-Jul-03 0:50 
I think you don't understand really the printf function. The sqrt is NOT a function, this is just text. So, when you see the first '%' that means that the second argument of the sprintf function (wich has a variable number of arguments) will be formated in a certain way, here: as a float!
Everything else that is not recognized as a formating string will be sent as TEXT characters to the output. You then have a second '%' wich take the third parameter (result) and format it as a float and send it as TEXT to the output. So, to answer your question: the square root is then taken from the argument list of the printf function!

Example:
if you enter 9 in your program, x will be 9. Then, in result you will have 3. Then your printf function can be "shown" as:
printf("sqrt(%lf) = %lf\n\",9,3); (I replaced x and result with their respective values.

So, this function will print the following STRING: sqrt(9.00000) = 3.00000
with 2 newlines (\n that are not formating string).
You can replace "sqrt" in the printf function by anything you want, it will work but print the other string instead of "sqrt"
GeneralRe: %1f\n? Pin
Rage8-Jul-03 1:11
professionalRage8-Jul-03 1:11 
GeneralRe: %1f\n? Pin
Cedric Moonen8-Jul-03 1:18
Cedric Moonen8-Jul-03 1:18 
GeneralRe: %1f\n? Pin
Steve S8-Jul-03 2:30
Steve S8-Jul-03 2:30 
GeneralRe: %1f\n? Pin
DaveE9th8-Jul-03 9:08
DaveE9th8-Jul-03 9:08 
GeneralOpen Website with "POST" Pin
AnTri7-Jul-03 22:27
AnTri7-Jul-03 22:27 
GeneralRe: Open Website with "POST" Pin
Iain Clarke, Warrior Programmer8-Jul-03 0:03
Iain Clarke, Warrior Programmer8-Jul-03 0:03 
GeneralRestore down button Pin
imajit7-Jul-03 22:09
imajit7-Jul-03 22:09 
GeneralRe: Restore down button Pin
Iain Clarke, Warrior Programmer7-Jul-03 23:58
Iain Clarke, Warrior Programmer7-Jul-03 23:58 
GeneralRe: Restore down button Pin
imajit8-Jul-03 1:06
imajit8-Jul-03 1:06 
GeneralRe: Restore down button Pin
Iain Clarke, Warrior Programmer8-Jul-03 1:42
Iain Clarke, Warrior Programmer8-Jul-03 1:42 
Generalto enter numeric value into an edit box Pin
Emre Zorlu7-Jul-03 22:03
Emre Zorlu7-Jul-03 22:03 
GeneralRe: to enter numeric value into an edit box Pin
Cedric Moonen7-Jul-03 22:16
Cedric Moonen7-Jul-03 22:16 
GeneralRe: to enter numeric value into an edit box Pin
Emre Zorlu7-Jul-03 22:25
Emre Zorlu7-Jul-03 22:25 
GeneralRe: to enter numeric value into an edit box Pin
Cedric Moonen7-Jul-03 22:40
Cedric Moonen7-Jul-03 22:40 
GeneralRe: to enter numeric value into an edit box Pin
Emre Zorlu7-Jul-03 22:44
Emre Zorlu7-Jul-03 22:44 
GeneralC++ compiler Pin
BoudewijnEctor7-Jul-03 21:33
BoudewijnEctor7-Jul-03 21:33 
GeneralRe: C++ compiler Pin
Rage7-Jul-03 22:42
professionalRage7-Jul-03 22:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.