码迷,mamicode.com
首页 > 编程语言 > 详细

c++ 字符串

时间:2018-07-26 13:20:17      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:style   clu   char   pig   ace   bsp   cout   void   ret   

1. c风格字符串,和strlen函数

#include "stdafx.h"
#include <iostream>
//using namespace std;
using std::cout;
using std::endl;
using std::cin;
int main(void)
{
    char dog[3] = { d,o,g };
    char pig[4] = { p,i,g,\0 };
    cout << strlen(dog) << endl;
    cout << strlen(pig) << endl;//输出结果为3,说明strlen是字符串中除\0外有效字符的个数
    cin.get();
    return 0;
}

 

c++ 字符串

标签:style   clu   char   pig   ace   bsp   cout   void   ret   

原文地址:https://www.cnblogs.com/heben/p/9370809.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!