This bug has been fixed in MATLAB 7.5 (R2007b). For previous product releases, read below for any possible workarounds:
Documentation on using C functions in MEX-files to prompt users for data is missing from the MATLAB external interfaces documentation. Here is additional information on using those functions:
The ability to access stdin or stdout is not available in MATLAB. Avoid trying to use printf and scanf in C MEX-files. To work around this issue:
1. Perform the input in MATLAB code, and design the MEX-file so that you pass the input value to the MEX-file.
2. Use mexCallMATLAB with the MATLAB function INPUT. Here is an example of how to do this:
mxArray *num_minutes, *str;
double out;
/* Replace the following two lines with the two code lines after them:
* printf("Enter number of minutes (0 - 59) = ");
* scanf("%d", #_minutes);
*/
str = mxCreateString("Enter number of Minutes (0 - 59) = ");
mexCallMATLAB(1,#_minutes,1,&str,"input");
/* The following is a test, to make sure we processed the input. */
out = mxGetScalar(num_minutes);
mexPrintf("This is really a double: %.0f ", out);
/* Need to free memory. */
mxFree(num_minutes);
mxFree(str);
Best Answer