They created a two-dimensional array of chars, and they also created a pointer to it. I want the pointer to point to a[0][1], so I did (*pa)++ (I know pa is the pointer to a, *pa is the pointer to the first row of a, and **pa is the pointer to the first value of the first row). I don't know why. Please help me ㅠ<
#include <stdio.h>
int main()
{
char a[100][100];
char (*pa)[100];
pa=a;
a[0][0]='a';
a[0][1]='e';
a[1][0]='g';
(*pa)++;
printf("%c\n",*(*pa+1));
}
The potential/post increment operator is only available for changeable lvalue.
++b
is equivalent to b = b+1
.
b++
is equivalent to temp = b; b = b + 1; temp
The value is eventually substituted for b
whether it is a potential or a posterior.
In order to substitute a value for b
, b
must be a variable.
If you look at (*pa)++
, *pa
is an array of characters with 100 elements.
The array is also converted to the address of the first element, so (*pa)
becomes the address value of a[0]
.
The address value is not a variable, so it is not a substitution operation. Potential/postal increment operator is not available because it is not a substitution operation.
Simply put, (*pa)++
is not allowed, such as why (1)++
is not allowed.
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
620 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.