string + int在C中执行什么操作? [英] What does string + int perform in C?
本文介绍了string + int在C中执行什么操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道这个表达式:
str + n
其中char str[STRING_LENGTH]
和int n
.
我在Java方面做了很多工作,直到现在一直以为它是字符串和整数的串联,对此我表示怀疑.
I have worked a lot in Java and was assuming till now that it's concatenation of string and integer, which I doubt now.
这是什么意思?
推荐答案
它是指针算法.例如:
char* str = "hello";
printf("%s\n", str + 2);
输出:llo
.因为str + 2
指向str
之后的2个元素,所以第一个l
.
Output: llo
. Because str + 2
point to 2 elements after str
, thus the first l
.
这篇关于string + int在C中执行什么操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文