-3

My code:

#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; 
    cin >> n; 

    while (n--) {
        string word; 
        cin >> word;

        if (word.length() > 10) {
            cout << word.front() << word.length() - 2 << word.back() << endl;
        } else {
            cout << word << endl;
        }
    }

    return 0;
}

Input:

4
word
localization
internationalization
pneumonoultramicroscopicsilicovolcanoconiosis

expected output:

word
l10n
i18n
p43s

Actual Output when pasted into VS Code’s external console

4
word
word
localization
l10n
internationalization
i18n
pneumonoultramicroscopicsilicovolcanoconiosis
p43s
Press any key to continue . . .  

How can I configure VS Code (or Windows Terminal / cmd.exe) so that it doesn’t echo pasted input, and only shows the program’s output cleanly below?
Is there a setting in launch.json or VS Code that can fix this behavior?

5
  • that's normal behavior of conhost.exe, try run it in files I/O instead of stdio Commented Nov 7 at 11:02
  • Not sure what you expect to happen. The output is exactly what you are expecting, but it needs to display the input you are typing, which is the "extra" lines you are seeing. Commented Nov 7 at 12:43
  • You can disable character echo'ing in conhost via: stackoverflow.com/questions/9217908/… Commented Nov 7 at 13:06
  • 1
    See Why should I not #include <bits/stdc++.h>? and What's the problem with "using namespace std;"?. Commented Nov 7 at 18:17
  • This question is similar to: How to disable echo in windows console?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Nov 14 at 21:14

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.