Why my colons look tight ? | SoloLearn: Learn to code for FREE!

+26

Why my colons look tight ?

I ran this code and you can clearly see a difference of spacing between the characters? What is happening ? https://code.sololearn.com/cq9D219s9I0R/?ref=app

2/23/2021 8:33:01 PM

#define CPP ChillPill

24 Answers

New Answer

+8

Hey! Bugs are just unintended features!

+9

Here's something: cout<<"\0" // Null value cout<<"\1" // a non printable value cout<<"\2" // a non printable value cout<<"\11" // horizontal tab So the output depends on how compiler prints these non printable characters . These all values are being treated as octal values even though they are not starting with literal 0 and It amazes me. Here's the list of what's printable and what's non printable https://web.itu.edu.tr/sgunduz/courses/mikroisl/ascii.html

+6

if i do: cout<< "\b"; it does the same

+6

it's probably a mix of sololearn output capture system and output display, wich would introduces some quirks ^^

+6

Mike are you challenging me. careful it might get messy. ;)

+5

Maybe need to code yourself a few laxatives πŸ˜‰

+4

visph a sololearn easter egg ?

+4

:D not really... I think rather a sololearn bug ;P

+4

It's called kerning ;)

+4

Diglett With Top Hat like I have pointed out already : "These all values are being treated as octal values..." So anything not in between [0,7] is an unknown escape sequence . here's the complete this http://www.asciitable.com/

+3

yeah i know. but why is it doing that ?

+3

seems to be any non printable characters: like '\b' is backspace. but still i wonder why would it mess up with the character spacing.

+3

while easter egg are hidden features ^^ in both cases, they are almost unuseful... if not annoying :(

+3

Hima Yeah, after I posted that answer I played with the code a little more, and found out that you can trigger errors related to octal values, the error that the compiler throws out says "warning: octal escape sequence out of range". Also, thanks for the link, it all makes sense now.

+2

It's because you had cout<< "\1"; Remove it and it works normal

+2

It's to do with the OCT value in the ascii table

+2

I'm unsure with that one. It could be perhaps a letter gets defaulted to a number 1 in the compiler? Or perhaps something else completely

+2

Fortis Militis i didnt mean to use '\1' specifically but I was trying to replicate some behavior i encountered in another code. i use '\0' at first then i tried '\1' simply because i like the "++" increment πŸ˜‰. yeah i remember msdos had the first emoji ever and it was char 1. i guess microsoft keep their inventions for long time. https://en.m.wikipedia.org/wiki/Code_page_437 the microsoft charset is pretty awesome to make character based games.

+2

like Pieter Edwards said, it seems to have something to do with ascii, i tried changing the value of cout << "\1"; to something like cout << "\126"; and it printed a letter, I think it prints the letter V (it only replaces the first character of the sentence though), also, don't try changing it to values like 80 or 90 because your code will error out saying "warning: unknown escape sequence".

+1

Copied and pasted the code in Visual Studio 2017 and it printed out the following: :::::::::: ☺:::::::::: has contemplated the "\1" to the emoji icon! Tested the same code in the Repl which runs on clang++-7 and it skipped the "\1" and only printed 2 rows of ":" Did you mean to print the emoji? what was the purpose of using the "\1" ?