Well, this being C++ why don't we take advantage of the STL and what it has to offer us. There are a couple of approaches to this, however lets keep things simple for now and just use std::vector and std::bitset. We can save the other advantages for later:
Code:
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
int main(void){
//Used to store each element of bcd (4 bit representation of number)
std::vector<std::bitset<4>>bcd;
std::string input;
std::cout <<"Enter number to convert(0-255):";
std::cin >> input;
//go through each number in the string and convert to binary representation
for(int i=0;i<input.size();i++){
std::bitset<4>number(input[i]-'0');//e.g.,converts char '2' to integer 2
bcd.push_back(number); //add the binary representation to our vector
}
//print out bcd
for(int j=0;j<bcd.size();j++){
std::cout<<bcd[j].to_string()<<" ";
}
return(0);
}