私は初心者で、以下の例を使用して配列へのポインターの概念を理解しようとしています。ループの終了条件を教えてもらえますか?
while ループは永久に実行されているように見えますが、プログラムは何も出力せずに終了します。
ありがとうございました。
typedef struct abc{
int a;
char b;
} ABC;
ABC *ptr, arr[10];
int main()
{
ptr = &arr[0];
int i;
for(i = 0; i < 10; i++){
arr[i].a = i;
}
while(ptr!=NULL){
printf("%d \n", ptr->a);
ptr++; //Can I use ptr = ptr + n to skip n elements for some n?
}
}