stringnxc

Change characters in string - Not Exactly C language


I need to change one character in string. In normal C, this is done simply by changing the offset:

char string[]="Somestring";
string[1] = 'a';   //"Samestring"

But in NXC such operation is not supported. So how do I change charecter on a string offset. NXC documentation about their strings has 3 lines, so I'm quite helpless now.


Solution

  • You can do it like this:

    string foo = "Somestring";
    foo[2] = 'a'; // results in "Samestring"