strcmp函数出现的有关问题

strcmp函数出现的问题
对字符数组处理,作比较,写了个小程序,用到了strcmp函数,但是有问题,请各位看一下。
#include<stdio.h>
#include<string.h>
void main()
{
  char string[10] = "i+1+2+i";
  int j,n;
  for(j=0; j<10; j++)
  {
      n = strcmp(&string[j], "i");
      printf("%d\n", n);
  
  }
  
}
结果为:1 -1 -1 -1 -1 -1 0 -1 -1 -1
第1个和第7个均为“i”,可是第一个比较却不为0,很奇怪
用gdb检查,p j 0, p string[j] "i", p n 1 (竟然不是0)
不知道怎么错了,请高手指点!
谢谢!

------解决方案--------------------
strcpy比较的是字符串,第一次比较的是"i+1+2+i"和"i",所以他们不等的。别忘了他们都是以0结束的,故最后一个是相等的。
------解决方案--------------------
比较字符不要用strcmp,直接判断即可:

#include<stdio.h>
#include<string.h>
void main()
{
  char string[10] = "i+1+2+i";
  int j,n;
  for(j=0; j<10; j++)
  {
      n = (string[j] == 'i');
      printf("%d\n", n);
  
  }
  
}

------解决方案--------------------
下面是循环比较过程:
j=0   "i+1+2+i" "i"
j=1   "+1+2+i" "i"
j=2   "1+2+i" "i"
...
j=6   "i" "i"
j=7   '\0' "i"
...

另外gcc下你的程序运行结果是:
43
-62
-56
-62
-55
-62
0
-105
-105
-105
是符合strcmp的规范的,看下面描述:

RETURN VALUES
     The strcmp() and strncmp() return an integer greater than, equal to, or
     less than 0, according as the string s1 is greater than, equal to, or
     less than the string s2.  The comparison is done using unsigned charac-
     ters, so that `\200' is greater than `\0'.

------解决方案--------------------
strncmp(&string[j], "i", 1);
才行。
strcmp比较是整个串,
------解决方案--------------------
另外,这个程序可能发生内存溢出。当j==9时,如果string[9]不是'\0',就会读到string[10]……溢出了