0

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.

Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778

1 Answers1

1

You can do it like this:

string foo = "Somestring";
foo[2] = 'a'; // results in "Samestring"
shea
  • 1,129
  • 2
  • 21
  • 38
  • Well, it seems there was some other error in my code, because this is exactly what I have tried. But thank you for assuring me about using the strings. – Tomáš Zato Oct 04 '13 at 13:28
  • @TomášZato I think is was the way you initialized the string variable – shea Oct 04 '13 at 22:17