Null Cipher | CPP program to decode NULL CIPHER ; Store the decoded string . ; found variable is used to tell that the encoded encoded character is found in that particular word . ; Set found variable to false whenever we find whitespace , meaning that encoded character for new word is not found ; Driver code ; Function call
#include <bits/stdc++.h> NEW_LINE using namespace std ; string decode ( string str ) { string res = " " ; bool found = false ; for ( int i = 0 ; i < str . size ( ) ; i ++ ) { if ( str [ i ] == ' ▁ ' ) { found = false ; continue ; } if ( ! found ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { res += str [ i ] + 32 ; found = true ; } else if ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) { res += str [ i ] ; found = true ; } } } return res ; } int main ( ) { string in ; in = " A ▁ Step ▁ by ▁ Step ▁ Guide ▁ for ▁ Placement ▁ Preparation ▁ by ▁ GeeksforGeeks " ; cout << " Enciphered ▁ Message : ▁ " ; cout << decode ( in ) << endl ; return 0 ; }