Follow

TIL

- C does not support function overloading

- the \v vertical tab character is kind of the equivalent of starting a new line and then indenting to the end of the previous line

I’m also trying to “stretch” my reading muscle. I really need to understand pointers and they look to be about 300 - 400 pages in the book so I need to read maybe a little faster and for longer each night then I’m used to.

Show thread

@derickflorian pointers will need practice, even then some people find them "difficult" to feel comfortable with. My first piece of advice along that way, is the use of spacing in C that is different than what is show in books. I prefer the pointer indication on a type (the asterisk) to be near the type and not near the variable.

So use (spaces exaggerated):

int* intPtr;

and not

int *intPtr;

The first reads "type of a pointer to an integer" the second "a variable that is a pointer"

@PHolder ok, the author of the book I’m reading knows his stuff then! So far he has only introduced char*.

Now that I think about it I like the way you mentioned because int* can be easily explained as a “pointer to an int”. In my limited experience with pointers I’ve had trouble explaining and understanding what * does in plain English. Especially because it’s also used to dereference pointers and get the value they hold.

@derickflorian that's LF (\n); as I understand it, VT is like LF but can go down several lines, depending on how you've set up the vertical tab stops in your teletype

@radehi Here is what happened when I tried it just now. It goes down and over for me.

I can't say when I would need this except for formatting poetry on the command line. :)

@derickflorian yeah, is the same thing \n does if your terminal is not configured to convert it to \r\n. \v is basically unused nowadays but in its day would move the printer down to the next printable line on the forms you were printing on

@radehi oh, ok. Thank you for the background. The book I’m reading just said that \r\n is on Windows and \n is linux so I didn’t know the history or the behind the scenes on how it works!

It makes sense that a new line would not go to beginning if there isn’t a carriage return though.

@derickflorian There is a stty setting on Linux, onlcr, where the kernel inserts a CR (\r) before each newline (\n, LF) before giving it to the terminal. Programs using cursor addressing usually turn this off.

Teletypes sometimes needed a delay, or maybe a few NUL characters, following the CR character to give the carriage time to return to the left margin before they could process more characters (such as the line feed to advance the paper). There are settings in stty for this as well (crN, ffN, nlN, ofill, ofdel).

Probably at this point we should just repurpose \v for something else.

@radehi I had no idea about any of this. I will definitely take a look at stty out of curiosity when I have a chance. That is extremely interesting especially with the historical context!

@derickflorian While some comdemn it, you can use macro in fancy ways, casting to a type or doing fancy things like passing the type as parameter or building a function generator (not so good).

The important is make it always work as a function emulating return with parenthesis operator (last member as return) or passing the calling to the correct real function.

@arkt8 that is really cool! I only talked about macros once with my mentor and he discouraged using macros except for symbolic constants. That said I would love to try that as an exercise when I become more advanced!

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.