Click here to Skip to main content
15,897,273 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
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 

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.