r - C++ / Rcpp - Changing a specific character in a string -


i'm new in c , c++, i´m using rcpp library in rstudio change character 's' 'z' when between vowels. i'm trying use iterator .at function t change 'z', line seems wrong. idea of i'm doing wrong?

// [[rcpp::depends(bh)]] #include <rcpp.h> #include <boost/algorithm/string.hpp>  //cc represents current_character #define cc   *i  string vowels = "aeiou";  /* define .begin .end functions  */  = word.begin();   while(i != word.end()){     if( cc == 's' && is(vowels,pc) && is(vowels,nc) ) {        // line below seems e wrong       word.at(i) == 'z';        += 1;     } else {         += 1;     }    } 

there lot of potential errors in program.

first @stephanlechner points out might not mean '==' in

word.at(i) == 'z';

the macro 'cc' incredible dangerous, @ least needs () better yet don't use it.

you have potential "off one" error in loop.

is(vowels,nc) 

might use 1 beyond end of word.

is(vowels,nc) 

nc what? if nc macro hides true value.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -