Untitled
unknown
plain_text
a year ago
499 B
7
Indexable
#include <iostream>
#include <cstring>
using namespace std;
void replaceChar(char *str, char a)
{
for (int i = 0; i < strlen(str); i++)
{
if (str[i] == a)
{
for (int curPos = i; curPos < strlen(str); curPos++)
{
str[curPos] = str[curPos + 1];
}
}
}
}
int main()
{
char str[] = "ghephetnhe";
char repl = 'h';
replaceChar(str, repl);
cout << str << endl;
return 0;
}Editor is loading...
Leave a Comment