-2

How can I replace a letter from one array to the letter from the other? And vice versa. For example a <-> x, b <-> y, c <-> z.

Code in C++ , please

txtText->setText(txtText->toPlainText().replace(prep[a],QString("x"))); txtText->setText(txtText->toPlainText().replace(prep[b],QString("y"))); txtText->setText(txtText->toPlainText().replace(prep[c],QString("z"))); 

or how? I don't understand

6
  • What "array"? A string? Commented Jun 5, 2013 at 19:16
  • 1st array - QString prep[3]={"a","b","c"} Commented Jun 5, 2013 at 19:19
  • 2nd - QString prep[3]={"x","y","z"} Commented Jun 5, 2013 at 19:19
  • 1
    And what exactly do you want to do with them? Update your question rephrased, it's incomprehensible as currently standing. Commented Jun 5, 2013 at 19:21
  • For example i have phrase "bad cat". I need to replace the letter so as to obtain like: "yxd zxt" Commented Jun 5, 2013 at 19:24

1 Answer 1

2

QString::replace is probably what you need.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.