Home > fmri > utils > GE2SPM > cstring.m

cstring

PURPOSE ^

SYNOPSIS ^

function str = cstring(x)

DESCRIPTION ^

CSTRING Print to a string like c
  CSTRING(x) takes an array x, of type char, and prints it to
  a string the way C would.
  the first null, or non-ascii character is the terminator

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function str = cstring(x)
0002 %
0003 %CSTRING Print to a string like c
0004 %  CSTRING(x) takes an array x, of type char, and prints it to
0005 %  a string the way C would.
0006 %  the first null, or non-ascii character is the terminator
0007 
0008 i=1;
0009 while (x(i)>0 & x(i)<128 & i<length(x))
0010   i=i+1;
0011 end
0012 
0013 if i==1
0014   str = char(0);
0015 else 
0016   str = char(x(1:i-1));
0017 end
0018 
0019 str = sprintf(str,'%s');
0020 
0021 return

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003