Click here to Skip to main content
15,906,626 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to do a ListBox by self? Pin
David12158-Jul-03 15:34
David12158-Jul-03 15:34 
GeneralADO connection pooling Pin
Imtiaz Murtaza8-Jul-03 0:09
Imtiaz Murtaza8-Jul-03 0:09 
Questioncout vs. printf? Pin
DaveE9th7-Jul-03 23:56
DaveE9th7-Jul-03 23:56 
AnswerRe: cout vs. printf? Pin
Rage8-Jul-03 0:42
professionalRage8-Jul-03 0:42 
GeneralRe: cout vs. printf? Pin
Rickard Andersson208-Jul-03 2:15
Rickard Andersson208-Jul-03 2:15 
GeneralRe: cout vs. printf? Pin
Rage8-Jul-03 3:23
professionalRage8-Jul-03 3:23 
GeneralRe: cout vs. printf? Pin
Ryan Binns8-Jul-03 3:50
Ryan Binns8-Jul-03 3:50 
GeneralRe: cout vs. printf? Pin
keegan8-Jul-03 3:23
keegan8-Jul-03 3:23 
AnswerRe: cout vs. printf? Pin
AlexO8-Jul-03 3:59
AlexO8-Jul-03 3:59 
GeneralRe: cout vs. printf? Pin
DaveE9th8-Jul-03 8:16
DaveE9th8-Jul-03 8:16 
Questionbinary sort function? Pin
DaveE9th7-Jul-03 23:08
DaveE9th7-Jul-03 23:08 
AnswerRe: binary sort function? Pin
Ryan Binns7-Jul-03 23:28
Ryan Binns7-Jul-03 23:28 
GeneralRe: binary sort function? Pin
DaveE9th8-Jul-03 0:17
DaveE9th8-Jul-03 0:17 
GeneralRe: binary sort function? Pin
Ryan Binns8-Jul-03 0:23
Ryan Binns8-Jul-03 0:23 
GeneralRe: binary sort function? Pin
Rage8-Jul-03 0:23
professionalRage8-Jul-03 0:23 
GeneralRe: binary sort function? Pin
DaveE9th8-Jul-03 7:58
DaveE9th8-Jul-03 7:58 
GeneralVC++ hangs... Pin
Rage7-Jul-03 22:56
professionalRage7-Jul-03 22:56 
GeneralRe: VC++ hangs... Pin
Toni788-Jul-03 15:20
Toni788-Jul-03 15:20 
Question%1f\n? Pin
DaveE9th7-Jul-03 22:55
DaveE9th7-Jul-03 22:55 
AnswerRe: %1f\n? Pin
Rage7-Jul-03 22:59
professionalRage7-Jul-03 22:59 
AnswerRe: %1f\n? Pin
Cedric Moonen7-Jul-03 23:05
Cedric Moonen7-Jul-03 23:05 
AnswerRe: %1f\n? Pin
Rage7-Jul-03 23:05
professionalRage7-Jul-03 23:05 
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 
[Also look at the cedcric's post to get infos]

OK. Obviously you are not familiar with the printf function Smile | :)

printf works as follow : it takes as parameters a string, plus a certain quantity of variables, whose value you want to display in the string. The way the things are displayed (the formatting) will be set up in the string using a % sign followed by characters indicated precision, width andtype of variable.

So in your program,

cin>>x;
result = sqrt (x);


will put the square root of x, which is the variable you type in wenn running the programm, in the variable result.

printf ("sqrt(%lf) = %lf\n\n", x, result );


This actually displays the string "sqrt(%lf) = %lf\n\n", replacing the first occurency of %+formatting with the value of x, the second one with the value of result (since x and result are the two other parameters of printf). lf means in this case that the type is a double. So the display would be "sqrt(4) = 2" + two return carriage(the two \n), leaving two blank lines in your console, if x=4.0 (so result =2.0 Smile | :) )

The \n is a special caractère such as \r (which puts the cursor to the beginning of the line) or \\ which displays a \. This has nothing to do with printf.


~RaGE();
GeneralRe: %1f\n? Pin
Ryan Binns8-Jul-03 0:50
Ryan Binns8-Jul-03 0:50 

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.