что я должен удалять или очищать и как я должен это делать?
Хочется как-то отойти от указания всех параметров а считать что есть некий контекст.
при замене почему то предпоследний элемент строки и столбца заменяется на случайное число из матрицы
void replaceColumn(int** matrix, int size) {
int maxRow = 0;
int maxElement = 0;
int copy;
// Находим строку с максимальным элементом
for (int i = 0; i < size; ++i) {
for (int j = 0; j < size; ++j) {
if (matrix[i][j] > maxElement) {
maxElement = matrix[i][j];
maxRow = i;
}
}
}
copy = matrix[maxRow][size - 2];
// Заменяем предпоследний столбец найденной строки
for (int i = 0; i < size; i++) {
matrix[i][size - 2] = (i == size - 2) ? copy : matrix[maxRow][i];
}
}
Как мне организовать систему сборки, чтобы любой пользователь мог запустить приложения, имея .exe файл и папку data ( aka DATA_DIR )
В чем тут фокус?
std::tm
-- это завёрнутая в namespace std struct tm
, древняя структура из чистого C. #include <time.h>
enum time_floor_level {
YEAR, MONTH, DAY, HOUR, MINUTE,
};
time_t time_floor(time_t t, enum time_floor_level level)
{
struct tm tm;
gmtime_r(&t, &tm);
switch (level) {
case YEAR:
tm.tm_mon = 0;
case MONTH:
tm.tm_mday = 1;
case DAY:
tm.tm_hour = 0;
case HOUR:
tm.tm_min = 0;
case MINUTE:
tm.tm_sec = 0;
}
return timegm(&tm);
}
Что означает ошибка «Error: relocation ... cannot be used with -shared»
gcc -fpic
). Из-за того что динамические библиотеки могут быть загружены в процесс по любому адресу существует требование, что код в них должен быть position-independent. Поэтому объектники скомпилированные как position-dependent обычно не могут быть слинкованы в динамическую библиотеку. R_AARCH64_TLSLE_ADD_TPREL_HI12
говорит (частью TLSLE, где LE означает Local Executable) о том, что код объектника в котором она находится был намеренно собран с рассчётом на то, что объектник будет частью исполняемого файла, а не динамической библиотеки. Здесь можно почитать об отличиях моделей адресации TLS, в частности о модели Local Exec в разделе 4.4. Почему возникает проблемы при закрытие файла
Больших отличий я не заметил
while (num_bor_1 <= num_bor_2)
{
if ((num_bor_1 % 2) != 1)
{
num_bor_1++;
}
}
do
{
num_bor_1++;
} while (num_bor_1 < num_bor_2);
Почему возникает free(): double free detected
String
копия получает то же значение str
что и оригинал с которого она скопирована, в деструкторе копия удаляет str
оригинала, а потом это же делает оригинал в своём деструкторе. См. правило трёх/пяти. IStream
который возвращает эта функция. third = string(buffer1);
fourth = string(buffer2);
third = string(buffer1, size3);
fourth = string(buffer2, size4);
char buffer1[size3];
…
char buffer2[size4];
wcout << endl << "Результат: " << encrypt(s);
Mixing operations on corresponding wide- and narrow-character streams follows the same semantics as mixing such operations on FILEs, as specified in the C standard library.
Each stream has an orientation. After a stream is associated with an external file, but
before any operations are performed on it, the stream is without orientation. Once a wide
character input/output function has been applied to a stream without orientation, the
stream becomes a wide-oriented stream. Similarly, once a byte input/output function has
been applied to a stream without orientation, the stream becomes a byte-oriented stream.
Only a call to the freopen function or the fwide function can otherwise alter the
orientation of a stream. (A successful call to freopen removes any orientation.)
Byte input/output functions shall not be applied to a wide-oriented stream and wide
character input/output functions shall not be applied to a byte-oriented stream.