字符指针和整数指针(++) [英] Character pointers and integer pointers (++)
本文介绍了字符指针和整数指针(++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个指针,
char *str1;
int *str2;
如果我看两个指针的大小,我们假设
If I look at the size of both the pointers let’s assume
str1=4 bytes
str2=4 bytes
STR1 ++由1字节递增,但如果STR2 ++将增加4个字节。
str1++ will increment by 1 byte, but if str2++ it will increment 4 bytes.
是什么概念背后?
推荐答案
简单,在提供的情况:
- char是1个字节长
- INT(在你的平台)为4个字节长
在 ++ 操作员通过有针对性的类型的大小递增指针。
The ++ operator increments the pointer by the size of the pointed type.
这篇关于字符指针和整数指针(++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文