MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Use strings in Mathematica, like in C?


Renan wrote:
> Hello,
> 
> In the C programming language I can operate directly over the
> characters of a string, like:
> 
> int main() {
> 
>  char message[16] = "Hello!";
>  message[n]='a';
> 
> /* ... other code ... */
>  return(0);
> 
> }
> 
> This mean: Change the (n+1)th character (in C, array starts at 0) to the
> specified character.
> 
> Q: How can I obtain similar effect in Mathematica?
> 
> Thanks!
> --
> Thanks/obrigado, Renan "Wishmaster" Birck - Canoas, Rio Grande do Sul, Brasil
> MSN: wizard_of_yendor at hotmail.com
> Orkut: http://www.orkut.com/Profile.aspx?uid=2202360379963855296
> 
Hi Renan,

Try

In[1]:=
StringReplacePart["Hello.", "!", {6, 6}]

Out[1]=
Hello!

In[2]:=
?*String*

lists all the commands for string manipulation.

Regards,
/J.M.


  • Prev by Date: Re: Use strings in Mathematica, like in C?
  • Next by Date: Re: Displaying Solution in Matrix Form
  • Previous by thread: Re: Use strings in Mathematica, like in C?
  • Next by thread: Re: Use strings in Mathematica, like in C?