摘要:
#include<iostream> using namespace std; int main() { //声明指针数组 const char *colors[] = { "red","blue","yellow","green" }; //指向指针的指针变量 const char **pt; / 阅读全文
posted @ 2021-07-06 14:29
江南王小帅
阅读(121)
评论(0)
推荐(0)
摘要:
C、C++中没有提供直接获取数组长度的函数,对于存放字符串的字符数组提供了一个strlen函数获取长度,那么对于其他类型的数组如何获取他们的长度呢?其中一种方法是使用sizeof(array) / sizeof(array[0]), 在C语言中习惯上在使用时都把它定义成一个宏,比如#define G 阅读全文
posted @ 2021-07-06 14:17
江南王小帅
阅读(6509)
评论(0)
推荐(0)
摘要:
#include <iostream> using namespace std; template int getArrayLen(T& array) //使用模板定义一个函数getArrayLen,该函数将返回数组array的长度 { return (sizeof(array) / sizeof( 阅读全文
posted @ 2021-07-06 14:11
江南王小帅
阅读(124)
评论(0)
推荐(0)
摘要:
#include <iostream> using namespace std; int main() { //声明字符型数组和指针变量 char str[10]; char *strip = str; //输入输出 cout << "str = "; cin >> str;//用字符数组输入字符串 阅读全文
posted @ 2021-07-06 09:41
江南王小帅
阅读(107)
评论(0)
推荐(0)
摘要:
#include <iostream> using namespace std; int main() { //声明数组、变量和指针变量 int a[] = { 1,2,3,4,5,6 }; int *ip1, *ip2; //测试指针的赋值运算 ip1 = a; ip2 = ip1; cout < 阅读全文
posted @ 2021-07-06 09:25
江南王小帅
阅读(46)
评论(0)
推荐(0)
摘要:
#include <iostream> using namespace std; int main() { //声明数组、变量和指针变量 int a[2][3], i, j; int *ip; //从键盘上为数组a赋值 for ( i = 0; i < 2; i++) { for ( j = 0; 阅读全文
posted @ 2021-07-06 09:15
江南王小帅
阅读(218)
评论(0)
推荐(0)

浙公网安备 33010602011771号