BAD!
There is a potential for an infinite loop and/or serious buffer overflow here.
You need to understand how characters are stored in memory to understand why this is so bad. A 'char' is an integer type. It stores a number in the range 0...255 or -127...127 (depending on whether it's unsigned or signed). But it's just a number. I could write:
char c = 1;
c++;
c *= 2;
// c now contains 4!
just like any other integer variable type. Now, second point: when you think you are storing letters in 'char' variables, you aren't. You're really just storing numbers. But when you use a function like putchar() or something to output a character to stdout, the function internally goes to the ASCII translation tables, looks up the symbol associated with the number stored in the 'char' variable, and spits that out. So the key point is this: the argument to a function like putchar() is
just a number. I could do putchar(97); and something would be output to the screen (I think it's lowercase 'a').
Now, once we understand that, let's look back at the code.
This test:
i <= word[i];
actually checks to see whether the counter variable 'i' is less than or equal to the
NUMBER stored in word[i]. That number is the ASCII representation of whatever word was entered earlier in the program. But it's still just a number. The loop will terminate only when i > word[i] for some i. So I could easily craft an attack on your program where I input word[i] = (i-1) for all i or something, and then i <= word[i] always, and this loop will never terminate. Or, alternatively, you would run right off the end of your 256-character 'word' buffer into memory you have not allocated. BAD! No guarantees what would happen.
By the way, the way this actually 'encodes' is just to spit out the ASCII representation of each character you have input. So if I wrote 'abc', the program would spit out the ASCII code for 'b' (98, I think), followed by the ASCII code for 'c' (99, I think). (check me on this). It starts at 'b' because you started i at 1 instead of 0. The reason it does this is because the overloaded cout << operator will output 'char' variables as their ASCII character equivalents (like putchar), but 'int' variables just as the pure numbers the ASCII characters correspond to. So the only reason this 'encodes' at all is because you have basically implicitly cast word[i] to an int by setting b=word[i]. If you just wrote word[i] to cout, you would do nothing more than write the input out to the output.
As a result, I could write a decoder for this just by repeated use of putchar()! The user gives me numbers, I putchar() them. voila! decoded. (I guess I would have to figure out how the digits break up into numbers, which would make it impossible. You would have to tell me where the digits break.)
Does this make sense? These are some pretty fundamental concepts about how characters are represented as numbers. Let me know if you have any questions.