RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-239139

Samvel's questions

Martin Hope
Samvel
Asked: 2020-07-24 17:32:44 +0000 UTC

模式和明确的专业化。C++

  • 1

有这样的模式。

template<class T>
T maxn(T *, int);

和专业化char*

template<> char* maxn(char**, int);

现在我还想添加const,即 T maxn(const T *, int);,但是在将其添加到 specialization 之后const,会引发错误,即 maxn红色下划线。

template<> char* maxn<char*>(const char**, int);

为什么?谁来解释?

c++
  • 2 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-03-08 22:50:49 +0000 UTC

从随机文件夹调用脚本[重复]

  • 1
这个问题已经在这里得到了回答:
如何在终端中按名称执行 bash 脚本? (2 个回答)
4年前关闭。

有一个脚本script.sh它位于~/Desktop/scripts/. 如果你去那里并通过终端运行它,那么它就可以工作。如何使它可以从任何文件夹中调用它?那些。如果我在一个文件夹~/Downloads中并且在终端中我编写了一个脚本调用bash script.sh,那么它就会启动

bash
  • 2 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-02-12 19:49:33 +0000 UTC

在 C 中存储 int* 的堆栈实现

  • 0

C中有一个实现的堆栈数据结构。

// C program for array implementation of stack
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

// A structure to represent a stack
struct Stack
{
    int top;
    unsigned capacity;
    int* array;
};

// function to create a stack of given capacity. It initializes size of
// stack as 0
struct Stack* createStack(unsigned capacity)
{
    struct Stack* stack = (struct Stack*) malloc(sizeof(struct Stack));
    stack->capacity = capacity;
    stack->top = -1;
    stack->array = (int*) malloc(stack->capacity * sizeof(int));
    return stack;
}

// Stack is full when top is equal to the last index
int isFull(struct Stack* stack)
{   return stack->top == stack->capacity - 1; }

// Stack is empty when top is equal to -1
int isEmpty(struct Stack* stack)
{   return stack->top == -1;  }

// Function to add an item to stack.  It increases top by 1
void push(struct Stack* stack, int item)
{
    if (isFull(stack))
        return;
    stack->array[++stack->top] = item;
    printf("%d pushed to stack\n", item);
}

// Function to remove an item from stack.  It decreases top by 1
int pop(struct Stack* stack)
{
    if (isEmpty(stack))
        return INT_MIN;
    return stack->array[stack->top--];
}

我对其进行了更改,以便它存储 int* 而不是 int。

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

struct StackNode
{
  int* data;
  struct StackNode* next;
};

struct StackNode* newNode(int* data)
{
  struct StackNode* stackNode =
    (struct StackNode*) malloc(sizeof(struct StackNode));
  stackNode->data = data;
  stackNode->next = NULL;
  return stackNode;
}

int isEmpty(struct StackNode *root)
{
  return !root;
}

void push(struct StackNode** root, int* data)
{
  struct StackNode* stackNode = newNode(data);
  stackNode->next = *root;
  *root = stackNode;
  printf("%d pushed to stack\n", data);
}

int* pop(struct StackNode** root)
{
  if (isEmpty(*root))
    return INT_MIN;
  struct StackNode* temp = *root;
  *root = (*root)->next;
  int* popped = temp->data;
  free(temp);
  return popped;
}

但很明显,因为线路的原因,它不起作用 return INT_MIN;

如何更改此行以使其正常工作?

c
  • 1 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-12-14 22:35:49 +0000 UTC

非整数指针类型

  • 2

我正在学习 LLVM IR。阅读LLVM 语言参考手册。我无法弄清楚这条线的含义。

非整数指针类型表示具有未指定按位表示的指针;也就是说,积分表示可能取决于目标或不稳定(没有固定整数支持)。

解释什么是非整数指针?

PS这个问题与翻译无关:D

llvm
  • 1 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-12-12 22:19:21 +0000 UTC

C 和 C++。指向 int 的指针(int*)

  • 0

这是C++中的代码

#include <iostream>
using namespace std;

int a;
int* b;

int main()
{
    int d = 5;
    b = &d;
    a = (int)b;
    return 0;
}

这是C中的相同代码

#include <stdio.h>

int a;
int* b;

int main()
{
    int d = 7;
    b = &d;
    a = (int)b;
} 

为什么相同的代码在 C 而不是 C++ 中工作。以及 C 如何将int* 转换为 int

c++
  • 2 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-11-16 13:40:35 +0000 UTC

模板。专长。C++

  • 1

你好。学习 C++(书:S. Prata)。有一个任务。在此处输入图像描述

有一个代码不起作用,因为(我知道 char*[] 选项是错误的。)如果您省略它,那么代码可以正常工作。

但是什么会更好呢?是否省略括号<>?如果上一个问题的答案是否定的,那么在 <> 中应该写什么?

这是代码。

#include <iostream>
#include <cstring>

template <typename T>
void maxn(T *, unsigned int);

template <> void maxn<char*[]>(char *array[], unsigned int n)
{
    char *p = array[0];

    for (int i = 1; i < n; ++i)
    {
        if (strlen(p) < strlen(array[i]))
            p = array[i];
    }

    std::cout << std::endl << "Line: " << p << " & Length: " << strlen(p);
}

int main()
{
    int arr_int[] = {3, 8, 0 ,9};
    maxn(arr_int, 4);

    double arr_double[] = {2.56, 0, 1, 3.567, 41.7, 7.87};
    maxn(arr_double, 6);

    char *p[] = {
                    ".....................",
                    ".................................",
                    ".............",
                    "**********************",
                    "^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
                 };
    maxn(p, 5);

    return 0;
}

template <typename T>
void maxn(T * arr, unsigned int n)
{
    T highest = arr[0];

    for (int i = 1; i < n; ++i)
    {
        if (highest < arr[i])
            highest = arr[i];
    }

    std::cout << std::endl << highest;
}
c++
  • 1 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-09-06 17:25:49 +0000 UTC

MySQL INNER JOIN - 字段列表中的“id”列不明确

  • 0

有一个要求:

SELECT
    `id`, `group_id`, `option_id`, `media_id`
FROM
    `s_articles` AS `articles`
INNER JOIN `s_article_configurator_set_group_relations` `set_groups` ON
    `articles`.`configurator_set_id` = `set_groups`.`set_id`
INNER JOIN `s_article_configurator_set_option_relations` `set_options` ON
    `articles`.`configurator_set_id` = `set_options`.`set_id`
RIGHT JOIN `s_articles_img` ON
    `articles`.`id` = (
    SELECT
        `articleID`
    FROM
        `s_articles_img`
    WHERE
        `articleID` IS NOT NULL);

执行时,显示错误:

Столбец 'id' в field list задан неоднозначно
mysql
  • 2 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-07-19 03:44:53 +0000 UTC

常用表达。.+ 对比*

  • 1

.+请解释和之间的区别.*。在我看来,他们都应该“输出、查找或下划线”文件中给出的所有文本。当我regexr.com写.+的时候它找到了所有的文本,但是当我写一个表达式的时候, .*显示了一个错误infinite。

PS 启用全局标志

регулярные-выражения
  • 1 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-07-06 23:06:43 +0000 UTC

MySQL二进制日志

  • 2

我无法启用二进制日志记录。我在互联网上发现可以通过取消注释log_bin = /var/log/mysql/mysql-bin.log配置文件中的行来启用二进制日志/etc/mysql/my.cnf。但是没有这样的项目。

这是该配置文件中的内容:

# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.

#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/

我进入文件夹/etc/mysql/conf.d/和/etc/mysql/mariadb.conf.d/文件mysqld.cnf,50-server.cnf找到并取消注释这些行,但仍然没有保留日志。

操作系统:Ubuntu 16.04

mysql
  • 1 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-06-26 03:23:37 +0000 UTC

什么时候转储 MySQL 合适?

  • 9

有一篇学期论文。课程作业的主题是“自动化注册办公系统”。好吧,你可以说我完成了工作,但由于登记处的数据非常重要,所以我决定编写一个脚本来制作dump数据库。

什么时候做才合适dump?也许每小时一次,或者每个工作日之后,或者数据库中的每次更改之后?

mysql
  • 2 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-06-13 23:12:36 +0000 UTC

数据库设计。ER模型

  • 1

推荐了《Hector Garcia-Molina, Jeffrey Ullman - Database Systems》这本书。每章末尾都有习题。书上说他们的网站有解决方案,但不是全部。帮助其中之一。

任务是这样的。

以 ER 图的形式表示“足球”数据库的结构,涵盖球队、球员和球迷的信息,包括以下属性:

  1. 对于每支球队——姓名、球员名单、队长姓名(来自球员)、球衣颜色;
  2. 对于每个玩家 - 一个名字;
  3. 每个球迷 - 姓名、球队名称、最喜欢的球员姓名和首选颜色。

请记住,set 不是有效的属性类型。在描述团队制服颜色时如何绕过这个限制?

这是我能画的

在此处输入图像描述

请更正我设计的ER项目。

база-данных
  • 1 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-06-09 18:16:45 +0000 UTC

php风暴。提交按钮不起作用

  • 0

有两个文件。首先

<!DOCTYPE HTML>

<HTML>
    <HEAD>
        <meta charset="utf-8">
        <style>
            .bottom_block
            {
                background-color: white;
                <!--border: 1px black solid;-->
                border-radius: 10px 10px 10px 10px;

                width: 20vw;
                height: 20vh;
                margin-left: 39.5vw;
                margin-top: 2px;
            }
        </style>
    </HEAD>

       <div class="bottom_block">
        <FORM method="post" action="admin_authentication.php">
            <div style="width: 90%; height: 15%; margin-left: 20%; margin-top: 5%">
                <input type="text" style="width: 70%; height: 77%" placeholder="Username" name="admin_username" required>
            </div>
            <div style="width: 90%; height: 15%; margin-left: 20%; margin-top: 5%">
                <input type="password" style="width: 70%; height: 77%;" placeholder="Password" name="admin_password" required>
                <br><br>
                <input type="submit" name='admin_send' style="width: 40%; height: 100%" value="Submit">
            </div>

        </FORM>
    </div>
</HTML>

第二个 admin_authentication.php

<?php
   echo $_POST['admin_username'];
   echo "Yes";
?>

$_POST['admin_username']当此代码通过“简单” (即安装在计算机上的)apache 运行时,它会打印出Yes. 但是当我从 PhpStorm 运行它时,它只给出Yes它可能是什么???

php
  • 1 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-06-03 05:32:46 +0000 UTC

MySQL。外键。创建表时出错

  • 0

为什么命令不起作用?

CREATE table Marriage (
        serial_num_husband varchar(30) NOT NULL FOREIGN KEY REFERENCES People(serial_number_passport),
        serial_num_wife varchar(30) NOT NULL FOREIGN KEY REFERENCES People(serial_number_passport));

给出错误信息

需要逗号或右括号。(在位置 71 的“FOREIGN KEY”附近)表达式的意外开始。(在位置 101 的“serial_number_passport”附近)表达式的意外开始。(在位置 133 的“serial_num_wife”附近)

PS 有一张表People有PRIMARY KEY serial_number_passport

mysql
  • 1 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-05-23 03:30:22 +0000 UTC

PHP。MySQL。比较

  • 2

代码不工作

if ($enter_login == mysqli_query($mysql_connect_link, "SELECT login FROM EMPLOYEE WHERE ID='$enter_id' "))

使用此代码

$m = mysqli_query($mysql_connect_link, "SELECT login FROM EMPLOYEE WHERE ID='$enter_id' ");
echo $m;

给出错误信息

可捕获的致命错误:第 8 行 /var/www/test.site/public_html/example.php 中类 mysqli_result 的对象无法转换为字符串

和代码

print_r($m);

问题

mysqli_result 对象 ( [current_field] => 0 [field_count] => 1 [lengths] => [num_rows] => 1 [type] => 0 )

好吧,从这里可以清楚地看出请求产生的东西与登录单元格中的不同

如何更改它以便有效。

我会这样说,以便请求给我单元格中写的内容。

php
  • 1 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-05-19 19:35:02 +0000 UTC

文字颜色。PHP

  • 0

编码

<?php
    printf("<span color='#%X%X%X'>Привет</span>", 65, 127, 245);
?>

给出了这个词Привет,但颜色是黑色的。为什么?

php
  • 1 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-05-19 18:08:09 +0000 UTC

唯一 ID 生成器

  • 0

我们需要一个唯一的 ID 生成器代码。上网查了一下。找到了一个函数 uniqid(),但不能保证唯一性。在 SO 上找到这篇文章。但是由于我是初学者,我不知道如何更改它(因为它不能正常工作)。告诉我怎么改?在您看来,它会发布唯一的 ID?

php
  • 2 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-05-18 04:32:59 +0000 UTC

庆典。CentOS 7. 定时任务

  • 0

您需要编写一个脚本,每小时都会在 /tmp 目录中创建一个文件并将其删除。上网查了一下。我了解到您需要使用 cron。有 cron.hourly 每 60 分钟执行一次操作。告诉我一个这样的脚本每 60 分钟运行一次的例子。

bash
  • 2 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-05-16 04:11:43 +0000 UTC

超高频射频识别。手机

  • 3

我在 Internet 上阅读,这与在具有 Android 操作系统(2.3 或更高版本)的手机上支持扫描 RFID 标签的事实有什么关系。这是真的?:D。我会这样问:有些电话带有 RFID 读取器。

android
  • 1 个回答
  • 10 Views
Martin Hope
Samvel
Asked: 2020-04-27 07:42:44 +0000 UTC

ip地址的分类

  • 6

什么是任播地址?它是做什么用的?

сеть
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5