Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralUsing __toascii() got me a runtime access violation Pin
glyfyx25-Feb-08 18:52
glyfyx25-Feb-08 18:52 
GeneralRe: Using __toascii() got me a runtime access violation Pin
Maxwell Chen25-Feb-08 19:03
Maxwell Chen25-Feb-08 19:03 
GeneralRe: Using __toascii() got me a runtime access violation Pin
Mark Salsbery25-Feb-08 19:17
Mark Salsbery25-Feb-08 19:17 
GeneralRe: Using __toascii() got me a runtime access violation Pin
Maxwell Chen25-Feb-08 19:46
Maxwell Chen25-Feb-08 19:46 
GeneralRe: Using __toascii() got me a runtime access violation Pin
Mark Salsbery26-Feb-08 5:16
Mark Salsbery26-Feb-08 5:16 
GeneralRe: Using __toascii() got me a runtime access violation Pin
glyfyx27-Feb-08 3:03
glyfyx27-Feb-08 3:03 
GeneralRe: Using __toascii() got me a runtime access violation Pin
Rajkumar R25-Feb-08 19:10
Rajkumar R25-Feb-08 19:10 
GeneralRe: Using __toascii() got me a runtime access violation Pin
Mark Salsbery25-Feb-08 19:12
Mark Salsbery25-Feb-08 19:12 
The arguments you pass to fprintf() need to match the format specifiers in the
format control string, in both type and number of arguments.

All the "%d"s in the format control string need a corresponding 32-bit integer argument passsed...
All the "%s"s in the format control string need a corresponding pointer to a null-terminated string passed.

The version where you don't pass the c argument  only appears to work, since you pass 5 arguments
when the format control string specifies an expected 6 arguments.

The version that crashes probably fails because c is a char but the format specifier is %s, which means
the passed argument should be a pointer to a NULL-terminated string, not a single character.

If you do something like this, it should work:

char c<font color="Red">[2]</font>;
c<font color="Red">[0]</font> = (char)__toascii(keyCode);
<font color="Red">c[1] = '\0';</font>
keyCode = p->vkCode;
...
nLen = fprintf(fOut,"kcK=%d ud=%s kc=%d sh=%d ti=%d %s\n",cb.kcK,updn,keyCode,Shift,tick, c);

Mark




Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralWithout Installing How to MatLab run when VC++ Button Pressed... Pin
johnalek25-Feb-08 18:42
johnalek25-Feb-08 18:42 
QuestionHow to Configure the Matlab Add-in for Visual Studio vc++ 6.0 Pin
johnalek25-Feb-08 18:36
johnalek25-Feb-08 18:36 
GeneralUnlocking a file.. Pin
sharanu25-Feb-08 17:44
sharanu25-Feb-08 17:44 
AnswerRe: Unlocking a file.. Pin
Rajkumar R25-Feb-08 17:58
Rajkumar R25-Feb-08 17:58 
GeneralRe: Unlocking a file.. Pin
sharanu25-Feb-08 19:04
sharanu25-Feb-08 19:04 
AnswerRe: Unlocking a file.. Pin
Rajkumar R25-Feb-08 20:31
Rajkumar R25-Feb-08 20:31 
GeneralRe: Unlocking a file.. Pin
sharanu25-Feb-08 20:48
sharanu25-Feb-08 20:48 
AnswerRe: Unlocking a file.. Pin
Rajkumar R25-Feb-08 21:42
Rajkumar R25-Feb-08 21:42 
QuestionHow to change the background color of AfxControlBar*, CToolBar's parent window ? Pin
Paresh Chitte25-Feb-08 17:22
Paresh Chitte25-Feb-08 17:22 
GeneralRe: How to change the background color of AfxControlBar*, CToolBar's parent window ? Pin
SandipG 27-Feb-08 22:46
SandipG 27-Feb-08 22:46 
GeneralRe: How to change the background color of AfxControlBar*, CToolBar's parent window ? Pin
Paresh Chitte28-Feb-08 17:27
Paresh Chitte28-Feb-08 17:27 
Questionhow to generate several Gaussian function according to different sigm Pin
gentleguy25-Feb-08 14:30
gentleguy25-Feb-08 14:30 
QuestionParallel Port Polling Pin
GlenET25-Feb-08 10:21
GlenET25-Feb-08 10:21 
GeneralRe: Parallel Port Polling Pin
Mark Salsbery25-Feb-08 11:04
Mark Salsbery25-Feb-08 11:04 
GeneralRe: Parallel Port Polling Pin
GlenET26-Feb-08 7:21
GlenET26-Feb-08 7:21 
GeneralRe: Parallel Port Polling Pin
Mark Salsbery26-Feb-08 7:51
Mark Salsbery26-Feb-08 7:51 
Generallistview item height Pin
Jim Crafton25-Feb-08 8:19
Jim Crafton25-Feb-08 8:19 

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.