关于指针循环变量的问题,脑袋要爆了。。。
正啃书中,遇到一个问题,百思不得其解,脑子就是转不过来弯了,请各位前辈帮忙解读一下程序代码:
#include<stdio.h> struct stu { int num; char *name; char sex; float score; }boy[5]={ {101,"Zhou ping",'M',45}, {102,"Zhang ping",'M',62.5}, {103,"Liou fang",'F',92.5}, {104,"Cheng lin",'F',87}, {105,"Wang ming",'M',58}, }; main() { struct stu *ps; printf("No\t Name\ttSex\tScore\t\n"); for(ps=boy;ps<boy+5;ps++) /*这个循环语句为什么要用指针做循环变量,还有<boy+5这个语句又是什么意思?*/ printf("%d\t%s\t%c\t%f\t\n",ps->num,ps->name,ps->sex,ps->score); }