首页 > 其他分享 >C primer plus 4.23 strlen函数

C primer plus 4.23 strlen函数

时间:2024-08-02 18:57:09浏览次数:7  
标签:name zd plus printf sizeof primer strlen PRAISAE

一、strlen函数

        **用来给出字符串的长度

#include<stdio.h>
#include<string.h>
#define PRAISAE "You are am extraordinary being."
int main(void)
 

{
    char name[40];

    printf("What your name?");
        scanf("%s", name);
        printf("Hello,%s.%s\n", name, PRAISAE);
        printf("Your name of %zd letters occupies %zd memory cell.\n",strlen(name),sizeof name);
        printf("Your name of %zd letters occupies %zd memory cell.\n", strlen(PRAISAE), sizeof PRAISAE);    \\注意到这里的sizeof没有使用圆括号,,当运算对象是类型时,圆括号必不可少,                             但对于特定量则,可有可无。(sizeof(char),sizeof name)

        return 0;

}

        **上面的程序使用了两种方式处理很长的printf语句

        **1、第一种将printf语句分为两行

        **2、使用两行printf打印一行内容

二、string.h头文件

        **包含多个与字符串相关的函数原型(如考本字符串的函数和字符串查找函数)

标签:name,zd,plus,printf,sizeof,primer,strlen,PRAISAE
From: https://blog.csdn.net/xnglan/article/details/140877759

相关文章

  • mybatis-plus 自定义sql拼接 的方式进行Wrapper条件查询 实现了分页 多表查询
    法一:用单表的思想(可以跳过,直接看法二)方法:先收集公共字段到集合中,再批量查询,然后封装起来缺点:相较于法二,代码量大,多访问了一次数据库service层:@Service@RequiredArgsConstructorpublicclassProductServiceImplextendsServiceImpl<ProductMapper,Product>implements......
  • C primer plus 第四章 4.2字符串简介
    一、什么是字符串:    是一个或多个字符的序列(被双引号引起来的就是字符串),单引号引起来的是字符,字符串=字符+空字符二、char类型和null字符:    *C中没有专门储存字符串的变量,字符串被储存在char类型的数组中。     数组:由连续的储存单元组成,字符串......
  • Mybatis-Plus源码-自增主键填充到实体
     #mybatis-3.5.10+mybatisPlus-3.5.2#mybatis-plus自增id策略下何时填充id到实体com.baomidou.mybatisplus.extension.service.impl.ServiceImpl#saveOrUpdatecom.baomidou.mybatisplus.extension.service.IService#savecom.baomidou.mybatisplus.core.override.M......
  • vue使用Element-plus创建个性按钮
    npminstallelement-plus--save下载element-plus2.npminstall-Dunplugin-vue-componentsunplugin-auto-import导入方式:自动导入不需要安装插件3.配置文件将:importAutoImportfrom'unplugin-auto-import/vite'importComponentsfrom'unplugin-vue-components/vi......
  • Vue3+elementplus遇到的常见问题
    1.跳转同一个路由的时候,只是参数不一样页面不刷新,不会执行onMounted尝试多种方案,包括watch等最终解决方案:router-view设置key属性为路由的完整路径<keep-alive><router-view:key="$route.fullPath"></router-view></keep-alive>eg:左侧菜单是接口返回的  默......
  • Log4cplus导入QT5(VSCode)
    下载GitHub地址:https://github.com/log4cplus/log4cplus版本选择log4cplus-2.0.2编译环境搭建完成后即可CMake编译生成预编译库,可参考该项目README.md进行功能选择导入在实际工程CMakeLists.txt中导入头文件(库include目录),并链接预编译好的.dll文件到项目中运行及调试la......
  • element-plus中el-container组件的重要用法详解
    el-container是ElementPlusUI框架中的一个布局容器组件,用于实现页面的布局结构。它主要用于管理和组织页面中的内容,提供了灵活的布局方式。下面详细解释一下el-container的重要用法和特性:1.基本用法el-container提供了三种基本布局方式:horizontal、vertical和vertica......
  • ElementPlusError: [ElOnlyChild] no valid child node found
    1.在使用elementplus表格操作按钮,使用v-if,作用元素,出现如下报错:ElementPlusError:[ElOnlyChild]novalidchildnodefound代码如下:<el-table-columnlabel="操作"align="center"fixed="right"width="150"class-name="small-paddingf......
  • Python的PyInputPlus模块
    PyInputPlus模块简介PyInputPlus模块的功能:PyInputPlus模块是一个Python第三方模块,需要自己对它进行安装。包含与input()函数类似的、用于多种数据(如日期、数字、电子邮箱地址等)的函数。如果,用户输入了无效的内容,例如格式错误的日期或超过预期范围的数字,那么PyInputPlus模......
  • MyBatis-Plus学习笔记
    使用SpringBoot创建工程并添加依赖pom.xml版本:SpringBoot2.3JDK1.8<?xmlversion="1.0"encoding="UTF-8"?><!--定义项目元数据,基于MavenPOM4.0.0模型--><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.......