Найти в Дзене
Cи

Брайн Кениган / Деннис Ритчи 3 издание. Упражнения.
подборка · 11 материалов
3 года назад
Создание модуля ядра
sudo apt install linux-source sudo tar jxf /usr/src/linux-source-5.15.0.tar.bz2 sudo make menuconfig sudo apt-get install libc6-devsudo apt-get install build-essential sudo make menuconfig ps -ax smod tail -f /var/log/kern.log вывод модуля - sudo insmod ./hello.ko удаление модуля - sudo rmmod ./hello.ko ДЗ: 1. вывод числовое значение - на экран ? 2. вывод hello в лог содержимое файла //hello.c *********************** #include <linux/module.h> MODULE_LICENSE("GPL"); MODULE_AUTHOR("IVS <a@a.ru>"); static int __init hello_init(void) { printk(KERN_ALERT...
3 года назад
UB, undefined behavior en.cppreference.com/.../ub Undefined behavior C++ C++ language Basic Concepts Renders the entire program meaningless if certain rules of the language are violated. Explanation The C++ standard precisely defines the observable behavior of every C++ program that does not fall into one of the following classes: ill-formed - the program has syntax errors or diagnosable semantic errors. A conforming C++ compiler is required to issue a diagnostic, even if it defines a language extension that assigns meaning to such code (such as with variable-length arrays). The text of the standard uses shall, shall not, and ill-formed to indicate these requirements. ill-formed, no diagnostic required - the program has semantic errors which may not be diagnosable in general case (e.g. violations of the ODR or other errors that are only detectable at link time). The behavior is undefined if such program is executed. implementation-defined behavior - the behavior of the program varies between implementations, and the conforming implementation must document the effects of each behavior. For example, the type of std::size_t or the number of bits in a byte, or the text of std::bad_alloc::what. A subset of implementation-defined behavior is locale-specific behavior, which depends on the implementation-supplied locale. unspecified behavior - the behavior of the program varies between implementations, and the conforming implementation is not required to document the effects of each behavior. For example, order of evaluation, whether identical string literals are distinct, the amount of array allocation overhead, etc. Each unspecified behavior results in one of a set of valid results. undefined behavior - there are no restrictions on the behavior of the program. Examples of undefined behavior are data races, memory accesses outside of array bounds, signed integer overflow, null pointer dereference, more than one modifications of the same scalar in an expression without any intermediate sequence point (until C++11)that is unsequenced a pointer of a different type, etc. Compilers are not required to diagnose undefined behavior (although many simple situations are diagnosed), and the compiled program is not required to do anything meaningful.
3 года назад
Разбор задач к разделу «Базовые конструкции C++»
Напишите программу, печатающую на экране первые строчки со страницы Бьярне Страуструпа про C++: C++ is a general-purpose programming language with a bias towards systems programming that - is a better C - supports data abstraction - supports object-oriented programming - supports generic programming. #include <iostream> int main() { std::cout << R"~~~(C++ is a general-purpose programming...
3 года назад
Упражнение 1.5 C->F
#include <stdio.h> int main(void) { float celsius, fahr; int lower, upper, step; lower = -17; upper = 149; step = 11; printf("\n\tТАБЛИЦА ТЕМПЕРАТУР\n\n"); printf("Градусы Цельсия\tГрадусы Фаренгейта\n\n"); celsius = lower; while (celsius <= upper) { fahr = 9.0 / 5.0 * celsius + 32; printf("%8.0f\t%10...
3 года назад
Упражнение 1.5 F->C
#include <stdio.h> /*lesson 1.5*/ int main() { float fahr, celsius; int lower, upper, step; lower = 0; upper = 300; step = 20; fahr = lower; while (fahr <= upper) { celsius = (5.0 / 9.0) * (fahr - 32.0); printf("%3.0f %6.1f\n", fahr, celsius); fahr = (fahr + step); } } /*----------------------------------------------*/ int main() { int fahr; for (fahr = 0; fahr <= 300; fahr = fahr + 20) printf ("%3d %6...
3 года назад
https://ru.wikibooks.org/wiki/Vim