Telegram Group & Telegram Channel
Зацените, какие штуки оказывается можно делать в си:

#include <stdio.h>

int sum(a, b) int a; long b;
{
return a + b;
}
int main() {
printf("%d\n", sum(1, 3));
return 0;
}

https://godbolt.org/z/TfWhjdb74

Вообще на сишный код не похоже)

Эта штука называется K&R C, но что-то полезное лучше искать по K&R definition style. Такой стиль поддерживается компиляторами си, но не c++.

В частности из-за этого стиля void foo(); это не "функция принимающая 0 аргументов", а "функция без прототипа". Из-за чего такой код компилируется, хотя и может приводить к УБ:


#include <stdio.h>

int sum() {
return 5;
}
int main() {
printf("%d\n", sum(1, 3));
return 0;
}


Однако, в 23 стандарте запретили объявлять функции без прототипов, поэтому там код уже компилироваться не будет:
https://godbolt.org/z/qd4KW4PMc

До 23 стандарта получить ошибку компиляции в таком коде можно, если добавить прототип (тут это уже функция принимающая 0 аргументов):


#include <stdio.h>

int sum(void) {
return 5;
}
int main() {
printf("%d\n", sum(1, 3));
return 0;
}


P.S.
Сам наткнулся на этот факт тут - https://habr.com/en/articles/786096/ (но надо читать еще и комменты, так как в статье есть ошибки)

Более подробно про прототипы можно глянуть вот тут:
https://stefansf.de/post/declaring-defining-and-prototyping-functions/



group-telegram.com/misha_writes_code/206
Create:
Last Update:

Зацените, какие штуки оказывается можно делать в си:


#include <stdio.h>

int sum(a, b) int a; long b;
{
return a + b;
}
int main() {
printf("%d\n", sum(1, 3));
return 0;
}

https://godbolt.org/z/TfWhjdb74

Вообще на сишный код не похоже)

Эта штука называется K&R C, но что-то полезное лучше искать по K&R definition style. Такой стиль поддерживается компиляторами си, но не c++.

В частности из-за этого стиля void foo(); это не "функция принимающая 0 аргументов", а "функция без прототипа". Из-за чего такой код компилируется, хотя и может приводить к УБ:


#include <stdio.h>

int sum() {
return 5;
}
int main() {
printf("%d\n", sum(1, 3));
return 0;
}


Однако, в 23 стандарте запретили объявлять функции без прототипов, поэтому там код уже компилироваться не будет:
https://godbolt.org/z/qd4KW4PMc

До 23 стандарта получить ошибку компиляции в таком коде можно, если добавить прототип (тут это уже функция принимающая 0 аргументов):


#include <stdio.h>

int sum(void) {
return 5;
}
int main() {
printf("%d\n", sum(1, 3));
return 0;
}


P.S.
Сам наткнулся на этот факт тут - https://habr.com/en/articles/786096/ (но надо читать еще и комменты, так как в статье есть ошибки)

Более подробно про прототипы можно глянуть вот тут:
https://stefansf.de/post/declaring-defining-and-prototyping-functions/

BY Миша пишет код




Share with your friend now:
group-telegram.com/misha_writes_code/206

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

The news also helped traders look past another report showing decades-high inflation and shake off some of the volatility from recent sessions. The Bureau of Labor Statistics' February Consumer Price Index (CPI) this week showed another surge in prices even before Russia escalated its attacks in Ukraine. The headline CPI — soaring 7.9% over last year — underscored the sticky inflationary pressures reverberating across the U.S. economy, with everything from groceries to rents and airline fares getting more expensive for everyday consumers. In addition, Telegram's architecture limits the ability to slow the spread of false information: the lack of a central public feed, and the fact that comments are easily disabled in channels, reduce the space for public pushback. The perpetrators use various names to carry out the investment scams. They may also impersonate or clone licensed capital market intermediaries by using the names, logos, credentials, websites and other details of the legitimate entities to promote the illegal schemes. The channel appears to be part of the broader information war that has developed following Russia's invasion of Ukraine. The Kremlin has paid Russian TikTok influencers to push propaganda, according to a Vice News investigation, while ProPublica found that fake Russian fact check videos had been viewed over a million times on Telegram. You may recall that, back when Facebook started changing WhatsApp’s terms of service, a number of news outlets reported on, and even recommended, switching to Telegram. Pavel Durov even said that users should delete WhatsApp “unless you are cool with all of your photos and messages becoming public one day.” But Telegram can’t be described as a more-secure version of WhatsApp.
from es


Telegram Миша пишет код
FROM American