Look! Smoke! Who do we blame? Recently, I found a way to generate specific blame for SmokeDetector. That was cool, so I decided to make a C++ program for it. I also have it on GitHub. This program is called Blame Bot.

Blame Bot does not need any flags to compile, so you can use make blame to compile it.

How it works:

Blame Bot takes an input of a number. This input is your chat id. This number is taken from your chat link. Mine would be: https://chat.stackexchange.com/users/301688/grant-garrison, and my number would be 301688. Then, the number is converted to base 7. A switch statement then outputs the characters. (Note: the characters must be in double quotes.)

#include &lt;iostream&gt;

int main(){
    int digit;
    std::string stringDigit, answer, instring;
    std::cin&gt;&gt;instring;
    int in = std::stoi(instring,nullptr);
    while (in != 0){
        digit = in % 7;
        if (digit &lt; 10){
            stringDigit = '0' + digit;
        }else{
            stringDigit = digit - 10 + 'A';
        }
            answer = stringDigit + answer;
            in /= 7;
    }
    std::cout&lt;&lt;"!!/blame\u180E ";
    int i = 0;
    while(answer.length()&gt;=i){
        switch (answer[i]-'0'){
            case 0: std::cout&lt;&lt;"\u180E";
                break;
            case 1: std::cout&lt;&lt;"\u200B";
                break;
            case 2: std::cout&lt;&lt;"\u200C";
                break;
            case 3: std::cout&lt;&lt;"\u200D";
                break;
            case 4: std::cout&lt;&lt;"\u2060";
                break;
            case 5: std::cout&lt;&lt;"\u2063";
                break;
            case 6: std::cout&lt;&lt;"\uFEFF";
                break;
        }
        i++;
    }
    std::cout&lt;&lt;"a\n";
}


What I'm looking for:

I'm looking for efficiency and syntax improvements. I know the program is fast already, but any extra computation cut out is a bonus. I do want to leave the { and } on the if statements though, as I think it improves readability for me. I also do not want to use any libraries.

What I think can be improved:

I think that switching back and forth from std::string and int is inefficient, and I'm sure there is a better way that doesn't need that. I also think that the base conversion algorithm might have a better replacement.
Spacing

The usage of (horizontal) space is not consistent, you have a space
after if and switch, but not after else and while. 
I would generally use more whitespace to increase the readability, in particular after keywords, around operators, etc. For example

while (answer.length() &gt;= i) {


Scope

It is a good habit to declare variables at the narrowest scope where they are used, and not at the top of the function. This applies for example
to digit and stringDigit, which are only used inside the while-loop.

Input validation

std::stoi(instring, nullptr) silently ignores leading whitespace
and trailing non-digits, that might or might not be wanted.
The pos parameter could be used to check if the complete string
has been converted successfully.

Also std::stoi(instring, nullptr) throws an std::invalid_argument
exception if the input string contains no valid digits at all,
you might want to catch that.

Iterating too far

In 

int i = 0;
while(answer.length()&gt;=i){
    switch (answer[i]-'0'){
        // ...
    }
    i++;
}


the last iteration accesses answer[answer.length()], which is
the null character. Even if this causes no harm (answer[i]-'0'
then matches none of the cases) it is probably unintended and you'll
want answer.length() &gt; i instead. (See below for further improvements
of this part.)

Simplifications

The remainder modulo 7 cannot be &gt;= 10, so the while loop
simplifies to

while (in != 0) {
    int digit = in % 7;
    std::string stringDigit;
    stringDigit = '0' + digit;
    answer = stringDigit + answer;
    in /= 7;
}


which can further be simplified to

while (in != 0) {
    char digit = '0' + in % 7;
    answer.insert(0, 1, digit);
    in /= 7;
}


making the stringDigit variable obsolete, and mutating answer
instead of concatenating strings.

Iterating over all valid string indices is better done with a for loop:

for (int i = 0; i &lt; answer.length(); ++i) {
    // ... use `answer[i]` ...
}


But actually you don't need the index, only the characters, and
iterating over all characters in a string can be done more simply
with a range-based for loop (added in C++ 11):

for (char&amp; c : answer)
    // ...
}


The switch statement can be replaced by an array lookup:

std::string blameStrings[] = {
    "\u180E", "\u200B", "\u200C", "\u200D", "\u2060", "\u2063", "\uFEFF"
};
for (char&amp; c : answer) {
    std::cout &lt;&lt; blameStrings[c - '0'];
}


(You can probably choose a better name for the array, but I have no
idea what those strings stand for.)

Get rid of the intermediate string storage

Your code computes answer as the base-7 representation of the
input number, and then iterates over the characters in that string.

The conversion from digits to characters in a string and back to
digits can be avoided by storing the integer digits in a vector
instead. And instead of prepending additional digits, we can append
them (to avoid that memory needs to be moved repeatedly) and then iterate
over the result in reverse order:

#include &lt;vector&gt;

// ...

int in = std::stoi(instring, nullptr);
std::vector&lt;int&gt; digits;
while (in != 0) {
    digits.push_back(in % 7);
    in /= 7;
}

std::cout&lt;&lt;"!!/blame\u180E ";
for (auto it = digits.rbegin(); it != digits.rend(); ++it) {
    std::cout &lt;&lt; blameStrings[*it];

}
std::cout&lt;&lt;"a\n";