B
B
bielokopytov042018-03-21 15:01:55
C++ / C#
bielokopytov04, 2018-03-21 15:01:55

C++ How to change a character to another one?

How to change a character in a certain place to another one?
#include
#include
using namespace std;
int main() {
char a[]="mad";
a[2]="n";
cout << a;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2018-03-21
@res2001

a[2]='n';
In double quotes, it is a null-terminated string, even if it contains 1 character. In single quotes, a character.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question