标签:des style blog http color os io 使用 ar
指针+1
int a[3][4] = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 } };//二维数组
int(*p)[4] = a; //数组指针
printf("%d\n", p); //8322788 这是个第一行的行地址,类似于二级指针
printf("%d\n", *p); //8322788 这是个第一行第一列的地址
printf("%d\n", **p); //0 这是第一个值
#include <stdio.h>
int main()
{
int a[3][4] = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 } };
int(*p)[4] = a;
for (int i = 0; i < 4;i++)
{
for (int j = 0; j < 3; j++)
{
printf("%d ",*(*(p+j)+i));
}
printf("\n");
}
return 0;
}
#include <stdio.h>
#include <string.h>
void str_cpy( char * dest , const char * src)
{
while(*dest++ = *src++);
}
int main()
{
char buf[100] = "aaaaaaaaaaaaaaaaaaaaaaaa";;
str_cpy(buf , "liuwei");
printf("%s\n" , buf);
return 0;
}
- #include <stdio.h>
#include <string.h>
void str_ncpy( char * dest , const char * src , int n)
{
while( (*dest++ = *src++) && n--);
*(dest-1) = 0;
}
int main()
{
char buf[5] = "aaaa";;
str_ncpy(buf , "liuweinihao" , 6);
printf("%s\n" , buf);
return 0;
}
#include <stdio.h>
int main()
{
int i;
char s[100] = "a刘威b";
printf("%d\n", s[0]);
printf("%d\n", s[1]);
printf("%d\n", s[2]);
printf("%d\n", s[3]);
printf("%d\n", s[4]);
printf("%d\n", s[5]);
return 0;
}
#include <stdio.h>
#include <string.h>
int mb_strlen(const char * p)
{
int len = 0;
while( *p )
{
len++;
if(*p++ < 0)
p++;
}
return len;
}
int main()
{
char *s = "a我b是c你d大e";
int len = mb_strlen( s );
printf("%d\n",len);
return 0;
}
标签:des style blog http color os io 使用 ar
原文地址:http://www.cnblogs.com/l6241425/p/3951386.html