Lädt...


🔧 Coding without braces: An alternate C Syntax


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

I recently stumbled upon an interesting piece of C language trivia that underscores how different computers were when C was first created. Specifically, C allows the use of digraphs (two letter combinations that represent a single letter) like <% and %> as alternatives of { and } and <: and :> as substitutes for [ and ]. The purpose of this was to provide an alternate syntax to support keyboards and character sets where braces and brackets were not available. The Gnu C Language manual mentions these digraphs as well as %: as an alternative to #. Since nothing on the internet can be trusted anymore I wrote a simple program and compiled it to verify the claims.

#include <stdio.h>

int main() <%
    printf("Hello, World!\n");
    int array<:5:> = <%1, 2, 3, 4, 5%>; 
    for (int i = 0; i < 5; i++) <%
        printf("%d\n", array<:i:>); 
    %>
    return 0;
%>

And lo and behold (don't take my word for it) it worked! While it's hard to imagine a keyboard without these symbols today, and I might be showing my ignorance of international keyboards here, I'm glad someone thought to include these alternatives.

But if the cpp reference is anything to go by there is is an expecation that all keyboards must have ?,< and ) as there is an even more verbose version of this behavior in the form of trigraphs, which allow a three character sequence alternative instead of two. Examples include ??< for { and ??) for ] but there are many more which can be viewed in the cpp reference. While tripgrahs appear to be going away in C23, I have no doubt people have abused these as well as digraphs in code obfuscation competitions.

Call To Action 📣

Hi 👋 my name is Diego Crespo and I like to talk about technology, niche programming languages, and AI. I have a Twitter a Mastodon, and Threads if you’d like to follow me on other social media platforms. If you liked the article, consider checking out my Substack. And if you haven’t why not check out another article of mine listed below! Thank you for reading and giving me a little of your valuable time. A.M.D.G

...

🔧 Coding without braces: An alternate C Syntax


📈 69.71 Punkte
🔧 Programmierung

🕵️ Medium CVE-2019-12893: Alternate-tools Alternate pic view


📈 30.3 Punkte
🕵️ Sicherheitslücken

🕵️ Medium CVE-2019-12894: Alternate-tools Alternate pic view


📈 30.3 Punkte
🕵️ Sicherheitslücken

🕵️ Medium CVE-2019-12895: Alternate-tools Alternate pic view


📈 30.3 Punkte
🕵️ Sicherheitslücken

🐧 Batch File Syntax: Understanding and Mastering the Syntax for Batch Scripting


📈 28.11 Punkte
🐧 Linux Tipps

🔧 From Solo Coding to Social Coding: Coding How SocialCode Makes Collaboration Easy


📈 26.9 Punkte
🔧 Programmierung

🔧 Yoko: Live coding without really coding.


📈 25.1 Punkte
🔧 Programmierung

🔧 Coding Without Coding


📈 25.1 Punkte
🔧 Programmierung

🕵️ CVE-2024-4067 | micromatch up to 4.05 index.js micromatch.braces redos (ID 243)


📈 24.37 Punkte
🕵️ Sicherheitslücken

📰 Europe Braces For Mobile Network Blackouts


📈 24.37 Punkte
📰 IT Security Nachrichten

📰 Video Game Sales Set To Fall For First Time in Years as Industry Braces For Recession


📈 24.37 Punkte
📰 IT Security Nachrichten

📰 Google Braces for Landmark Global Privacy Ruling


📈 24.37 Punkte
📰 IT Security Nachrichten

⚠️ Win32/Braces.A


📈 24.37 Punkte
⚠️ Malware / Trojaner / Viren

📰 America Braces For Daylight Saving Time - And Missing Medical Records


📈 24.37 Punkte
📰 IT Security Nachrichten

📰 FIFA admits hack and braces for new leaks


📈 24.37 Punkte
📰 IT Security Nachrichten

📰 FIFA, Hacked Again, Braces For New Revelations


📈 24.37 Punkte
📰 IT Security Nachrichten

📰 US Braces for Possible Cyberattacks After Iran Sanctions


📈 24.37 Punkte
📰 IT Security Nachrichten

📰 Philippine Outsourcing Industry Braces For AI


📈 24.37 Punkte
📰 IT Security Nachrichten

📰 Offshore Legal Firm Hacked, Braces for Media Leaks


📈 24.37 Punkte
📰 IT Security Nachrichten

📰 Yahoo! braces itself as judge rules that it’s on the hook for a class-action suit


📈 24.37 Punkte
📰 IT Security Nachrichten

📰 Industry Braces for Repeal of ISP Privacy Rules


📈 24.37 Punkte
📰 IT Security Nachrichten

📰 Kennedy Space Center Braces For Hurricane Matthew


📈 24.37 Punkte
📰 IT Security

📰 Kennedy Space Center Braces For Hurricane Matthew


📈 24.37 Punkte
📰 IT Security

🔧 Supercharge Your Coding: Using Google Gemini as an AI Coding Assistant in Visual Studio Code


📈 17.93 Punkte
🔧 Programmierung

🔧 Coding Training: How to Improve Your Coding Skills


📈 17.93 Punkte
🔧 Programmierung

🔧 Coding Skills Not Found. Share Your Funniest Coding Failures 💻💥🙈


📈 17.93 Punkte
🔧 Programmierung

🔧 C# Coding Convention: Coding Standard in C#


📈 17.93 Punkte
🔧 Programmierung

matomo