Click here to Skip to main content
15,888,521 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionOwner Button Width Pin
john563218-Dec-10 18:19
john563218-Dec-10 18:19 
AnswerRe: Owner Button Width Pin
Maximilien19-Dec-10 1:40
Maximilien19-Dec-10 1:40 
Question890927 - Invalid Input Format exception in sscanf_s Pin
ilostmyid218-Dec-10 1:48
professionalilostmyid218-Dec-10 1:48 
AnswerRe: 890927 - Invalid Input Format exception in sscanf_s Pin
ALLERSLIT18-Dec-10 2:59
ALLERSLIT18-Dec-10 2:59 
GeneralRe: 890927 - Invalid Input Format exception in sscanf_s Pin
ilostmyid218-Dec-10 3:19
professionalilostmyid218-Dec-10 3:19 
AnswerRe: 890927 - Invalid Input Format exception in sscanf_s Pin
Richard MacCutchan18-Dec-10 4:57
mveRichard MacCutchan18-Dec-10 4:57 
GeneralRe: 890927 - Invalid Input Format exception in sscanf_s Pin
ilostmyid218-Dec-10 7:53
professionalilostmyid218-Dec-10 7:53 
GeneralRe: 890927 - Invalid Input Format exception in sscanf_s Pin
Richard MacCutchan18-Dec-10 10:34
mveRichard MacCutchan18-Dec-10 10:34 
As it says in the link I showed: The width field is a positive decimal integer controlling the maximum number of characters to be read for that field. No more than width characters are converted and stored at the corresponding argument. Fewer than width characters may be read if a whitespace character (space, tab, or newline) or a character that cannot be converted according to the given format occurs before width is reached.


So in your case you would code it as

double a;
sscanf_s("0.02", "%4f", &a);

since you have 4 characters in your string value. The number of digits after the decimal point is largely irrelevant for floats and doubles when reading in, it is only important when formatting for output. In general you are better off not specifying a width value as it can lead to loss of precision in input strings - unless your users all know exactly what format to use for their input data.
Just say 'NO' to evaluated arguments for diadic functions! Ash

GeneralRe: 890927 - Invalid Input Format exception in sscanf_s Pin
ilostmyid218-Dec-10 18:52
professionalilostmyid218-Dec-10 18:52 
GeneralRe: 890927 - Invalid Input Format exception in sscanf_s Pin
Richard MacCutchan18-Dec-10 21:37
mveRichard MacCutchan18-Dec-10 21:37 
GeneralRe: 890927 - Invalid Input Format exception in sscanf_s Pin
ilostmyid219-Dec-10 0:29
professionalilostmyid219-Dec-10 0:29 
GeneralRe: 890927 - Invalid Input Format exception in sscanf_s Pin
Richard MacCutchan19-Dec-10 0:39
mveRichard MacCutchan19-Dec-10 0:39 
GeneralRe: 890927 - Invalid Input Format exception in sscanf_s Pin
ilostmyid219-Dec-10 0:49
professionalilostmyid219-Dec-10 0:49 
GeneralRe: 890927 - Invalid Input Format exception in sscanf_s Pin
jschell19-Dec-10 9:50
jschell19-Dec-10 9:50 
GeneralRe: 890927 - Invalid Input Format exception in sscanf_s Pin
ilostmyid222-Dec-10 19:42
professionalilostmyid222-Dec-10 19:42 
Question'Fake' the freespace of a hdd Pin
ALLERSLIT17-Dec-10 23:54
ALLERSLIT17-Dec-10 23:54 
AnswerRe: 'Fake' the freespace of a hdd Pin
Richard MacCutchan18-Dec-10 4:43
mveRichard MacCutchan18-Dec-10 4:43 
QuestionRe: 'Fake' the freespace of a hdd Pin
David Crow20-Dec-10 3:19
David Crow20-Dec-10 3:19 
QuestionFor Loop & Array Issue. Pin
Mike Certini17-Dec-10 10:48
Mike Certini17-Dec-10 10:48 
AnswerRe: For Loop & Array Issue. Pin
User 742933817-Dec-10 11:01
professionalUser 742933817-Dec-10 11:01 
QuestionMFC CArray vs Vectors [modified] Pin
Software200717-Dec-10 6:54
Software200717-Dec-10 6:54 
AnswerRe: MFC CArray vs Vectors Pin
«_Superman_»17-Dec-10 7:15
professional«_Superman_»17-Dec-10 7:15 
AnswerRe: MFC CArray vs Vectors Pin
Maximilien17-Dec-10 8:01
Maximilien17-Dec-10 8:01 
AnswerRe: MFC CArray vs Vectors Pin
CPallini17-Dec-10 9:38
mveCPallini17-Dec-10 9:38 
QuestionDT_CALCRECT Pin
john563217-Dec-10 5:48
john563217-Dec-10 5:48 

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.