comparison examples/mystring.c @ 16867:be41c30bcb44

Re-write documentation and all examples of dynamically linked functions. * doc/interpreter/dynamic.txi: deleted. * doc/interpreter/external.txi: Renamed from dynamic.txi. Rewrote or added much information about dynamically linked functions. * doc/interpreter/Makefile.am: Changed dynamic.txi to external.txi in build system. * doc/interpreter/data.txi, doc/interpreter/intro.txi, doc/interpreter/octave.texi, doc/interpreter/sparse.txi: Changed dynamic.txi to external.txi in cross-references. * doc/interpreter/doccheck/aspell-octave.en.pws: Added new words from external.txi to Octave dictionary. * examples/firstmexdemo.c: deleted. * examples/mex_demo.c: Renamed from firstmexdemo.c. Added many more comments to code. * examples/hello.cc: deleted. * examples/oct_demo.cc: Renamed from hello.cc. Added many more comments to code. * examples/Makefile.am: Changed build system to use mex_demo.c and oct_demo.cc. * examples/addtwomatrices.cc, examples/celldemo.cc, examples/embedded.cc, examples/fortdemo.cc, examples/funcdemo.cc, examples/globaldemo.cc, examples/helloworld.cc, examples/mycell.c, examples/myfeval.c, examples/myfunc.c, examples/myhello.c, examples/mypow2.c, examples/myprop.c, examples/myset.c, examples/mysparse.c, examples/mystring.c, examples/mystruct.c, examples/paramdemo.cc, examples/standalone.cc, examples/stringdemo.cc, examples/structdemo.cc, examples/unwinddemo.cc: Use Octave coding conventions for code. Fixed all compilation errors and warnings.
author Rik <rik@octave.org>
date Sat, 29 Jun 2013 18:08:24 -0700
parents 6cb30a539481
children 224e76250443
comparison
equal deleted inserted replaced
16866:a472bfc67b6c 16867:be41c30bcb44
1 #include <string.h> 1 #include <string.h>
2 #include "mex.h" 2 #include "mex.h"
3 3
4 void 4 void
5 mexFunction (int nlhs, mxArray *plhs[], int nrhs, 5 mexFunction (int nlhs, mxArray *plhs[],
6 const mxArray *prhs[]) 6 int nrhs, const mxArray *prhs[])
7 { 7 {
8 mwSize m, n;
8 mwIndex i, j; 9 mwIndex i, j;
9 mwSize m, n;
10 mxChar *pi, *po; 10 mxChar *pi, *po;
11 11
12 if (nrhs != 1 || ! mxIsChar (prhs[0]) || 12 if (nrhs != 1 || ! mxIsChar (prhs[0]) ||
13 mxGetNumberOfDimensions (prhs[0]) > 2) 13 mxGetNumberOfDimensions (prhs[0]) > 2)
14 mexErrMsgTxt ("expecting char matrix"); 14 mexErrMsgTxt ("ARG1 must be a char matrix");
15 15
16 m = mxGetM (prhs[0]); 16 m = mxGetM (prhs[0]);
17 n = mxGetN (prhs[0]); 17 n = mxGetN (prhs[0]);
18 pi = mxGetChars (prhs[0]); 18 pi = mxGetChars (prhs[0]);
19 plhs[0] = mxCreateNumericMatrix (m, n, mxCHAR_CLASS, 19 plhs[0] = mxCreateNumericMatrix (m, n, mxCHAR_CLASS, mxREAL);
20 mxREAL);
21 po = mxGetChars (plhs[0]); 20 po = mxGetChars (plhs[0]);
22 21
23 for (j = 0; j < n; j++) 22 for (j = 0; j < n; j++)
24 for (i = 0; i < m; i++) 23 for (i = 0; i < m; i++)
25 po [j*m + m - 1 - i] = pi [j*m + i]; 24 po[j*m + m - 1 - i] = pi[j*m + i];
26 } 25 }