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: |

In this regard, Sebi collaborated with the Telecom Regulatory Authority of India (TRAI) to reduce the vulnerability of the securities market to manipulation through misuse of mass communication medium like bulk SMS. Groups are also not fully encrypted, end-to-end. This includes private groups. Private groups cannot be seen by other Telegram users, but Telegram itself can see the groups and all of the communications that you have in them. All of the same risks and warnings about channels can be applied to groups. Channels are not fully encrypted, end-to-end. All communications on a Telegram channel can be seen by anyone on the channel and are also visible to Telegram. Telegram may be asked by a government to hand over the communications from a channel. Telegram has a history of standing up to Russian government requests for data, but how comfortable you are relying on that history to predict future behavior is up to you. Because Telegram has this data, it may also be stolen by hackers or leaked by an internal employee. And while money initially moved into stocks in the morning, capital moved out of safe-haven assets. The price of the 10-year Treasury note fell Friday, sending its yield up to 2% from a March closing low of 1.73%. 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.
from it


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