[C++]学习中的一个问题

C++ 复制代码
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main(){
    char str[31];
    cout << "--==--" << sizeof(str) << endl;
    // 给了
    memset(str, 0, sizeof(str));
    for (size_t i = 0; i < 31; i++)
    {
       cout << "qweqwe:" << i << " dd:" << (str[i]==0) <<"  ff:"<< str[i]<< endl;
    }
    cout << "-----------===========--" << str << endl;
    return 1;

为什么 == 0 是true,而打印出来没东西啊,是个初始化的问题,我不是

memset(str, 0, sizeof(str)); 把str的所有位置都置成0了么。

相关推荐
gugucoding1 分钟前
38. 【Java】Stream API(下):高级操作与性能
java·开发语言
Lhan.zzZ8 分钟前
在 Visual Studio 2022 中打造可扩展的动态链接库模块:从零搭建到原理解析
开发语言·c++·visual studio
小弥儿25 分钟前
GitHub今日热榜 | 2026-08-11:图原生基础设施首日登顶
学习·开源·github
心平气和量大福大28 分钟前
android-实例-蒲公英-更新与安装-5-签名与生成APK
android·java·开发语言
码哥DFS42 分钟前
构造函数、实例对象、对象原型 ----三者关系
开发语言·javascript·原型模式
quantdash_cc1 小时前
告别自建 Requests/BS4 网页爬虫:基于 QuantDash 搭建零维保的高性能量化行情流水线
开发语言·爬虫·python·pandas·量化·quantdash
ydd1001001 小时前
寻找两个正序数组的中位数 Java 题解,二分分割详解
java·开发语言
zh路西法2 小时前
【3D SLAM源码解读系列】(二)Small_gicp——5 个积木搭出最优点云配准
c++·pcl·icp·fastgicp·smallgicp·gicp
半亩码田2 小时前
C#转Python第3.1篇:Python 的 class 没有访问修饰符?面向对象的另一条路
开发语言·python·c#
Wzx1980123 小时前
python沙箱和docker沙箱你选对了吗?
开发语言·python·docker