[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了么。

相关推荐
贩卖纯净水.23 分钟前
webpack打包学习
前端·学习·webpack
景天科技苑37 分钟前
【Rust宏编程】Rust有关宏编程底层原理解析与应用实战
开发语言·后端·rust·rust宏·宏编程·rust宏编程
yorushika_1 小时前
python打卡训练营打卡记录day45
开发语言·python·深度学习·tensorboard
封奚泽优1 小时前
使用Python进行函数作画
开发语言·python
aningxiaoxixi1 小时前
JAVA之 Lambda
java·开发语言
yxc_inspire2 小时前
基于Qt的app开发第十三天
c++·qt·app·tcp·面向对象
come112342 小时前
Claude 写 PHP 项目的完整小白教程
开发语言·php
虾球xz2 小时前
CppCon 2015 学习:Concurrency TS Editor’s Report
开发语言·c++·学习
Moonnnn.2 小时前
【电赛培训课程】运算放大器及其应用电路设计
笔记·学习
潇-xiao2 小时前
Qt 按钮类控件(Push Button 与 Radio Button)(1)
c++·qt