标签: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; }
标签:style clu char pig ace bsp cout void ret
原文地址:https://www.cnblogs.com/heben/p/9370809.html