小编Cod*_*ity的帖子

字符转换函数 std::isupper() & std::islower() C++17

我创建了一个简单的程序来检查用户输入的字母是大写还是小写,然后使用std::isupper()andstd::islower()函数将小写转换为大写,将大写转换为小写。在运行代码时,我得到了数字形式的字符转换,而不是预期的大写/小写等价物。这是为什么?

#include <iostream>

int main()
{
    char letter {};

    std::cout << "Enter a letter:";

    std::cin >> letter;

    if (std::isupper(letter))
    {
        std::cout << "You entered an uppercase letter"
                     "\n"
                     "the lowercase equivalent is:"
                  << std::tolower(letter);
    }

    if (std::islower(letter))    
    {
        std::cout << "You entered a lowercase letter"
                     "\n"
                     "the uppercase equivalent is:"
                  << std::toupper(letter);
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

下面是一个输出示例:

Enter a letter:F
You entered an uppercase letter.
The lowercase equivalent is:102

Enter a letter:f
You entered a lowercase …
Run Code Online (Sandbox Code Playgroud)

c++ c++17

6
推荐指数
2
解决办法
189
查看次数

impish Release 不再有 Release 文件

我正在尝试,$ sudo apt update但我明白了:

Reading package lists... Done                                                                                                                        
E: The repository 'http://archive.ubuntu.com/ubuntu impish Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://archive.ubuntu.com/ubuntu impish-updates Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) …
Run Code Online (Sandbox Code Playgroud)

linux ubuntu ubuntu-21.04

6
推荐指数
1
解决办法
1万
查看次数

C++17 后增量操作

C++17

有人可以解释一下如何

int number{5};
number = (number++) + 10;
Run Code Online (Sandbox Code Playgroud)

给出 15 的输出,而

int number {5};
number = (++number) + 10;
Run Code Online (Sandbox Code Playgroud)

给出 16 的输出?

c++ c++17

1
推荐指数
1
解决办法
208
查看次数

数组大小确定 C++17

我正在尝试使用该std::size()函数确定数组的大小,但我的编译器带来了此错误:

/root/Desktop/practise.cpp:9:34: 错误:“size”不是“std”的成员;你的意思是“size_t”?

这是第一个代码:

#include <iostream>
#include <array>

using namespace std;

int main()
{

    int values [] {2,3,4,5,6,7,8,9,10};

    cout <<"The array size is:"<< std::size(values);


    return 0;
}
Run Code Online (Sandbox Code Playgroud)

在改变语句std::size(values)std::size_t(values),似乎并不准确弹出一个庞大的数字。输出的值为:

140725039324624

c++ c++17

-3
推荐指数
1
解决办法
83
查看次数

标签 统计

c++ ×3

c++17 ×3

linux ×1

ubuntu ×1

ubuntu-21.04 ×1