背景:
下述函数的作用,是将字符数组倒叙转化为整型数组,但是运行过程中,*b这种形式,就能正常赋值,输出;b[test_count]这种形式就不能正常赋值,输出
编译工具:Visual studio 2019
code:
void Invert(char* a, int* b)
{
int a_len = strlen(a), b_len_count = 0;
for (int a_count = a_len - 1; a_count>=0; a_count--)
{
char temp = a[a_count];
*b = temp - '0';
//printf("a[a_count]: %c\n", a[a_count]);
printf("*b: %d\n", *b);
b++;
//printf("%d\n", a_len);
}
int test_count = 0;
for (test_count = 0; test_count <= a_len - 1; test_count++)
{
printf("b[test_count]: %d\n", b[test_count]);
}
}