Hi, I want to copy "hello" letter by letter but when it hits e i want to skip it so that it prints "hllo"..I have used the following code but when it gets to e the rest of the letters don't show up. just prints the first letter with is the h...how can i make this work..thanks
char enterletters[]="hello";
char shi[]="e";
char copy_letter[50];
for (int ff=0; ff<5; ff++)
{
if (enterletters[ff]==shl[0])
++ff;
Replace ++ff; with continue;, and make sure to initialize copy_letter with all zeros, or copy the null terminator from enterletters:
char copy_letter[50] {};
Alternatively, do something like this:
1 2 3 4 5 6 7 8 9 10
# include <iostream>
# include <iterator>
# include <algorithm>
int main() {
static std::string const skip {"efg"}; // skip the characters appearing in this string
std::copy_if(std::istream_iterator<char>{std::cin}, {},
std::ostream_iterator<char>{std::cout},
[](charconst c) { return skip.find(c) == std::string::npos; } );
}
how do i make it so the "cin" is the variable and the "cout" would be the variable output, and it goes on to the next line. instead ot it repeating itself. also I would like were the letters to be a variable, also and I wanted only to have one letter removed so if the variable holds two 'ee' i only want one to be removed. thanks