Не поймите меня неправильно, но не совсем понял, что надо. Понял только, что надо C99 конвертировать в C++11(на 14-й пока не полагайтесь - поддержка в гцц сего нова и могут быть косяки).
Вот приложил причёсанный и конвертированный код
Код
#include <stdio.h>
void test(const int N, const int M, int *A)
{
using tA = int[M];
tA *pA = (tA*)A;
for(size_t i = 0; i < N; i++)
{
for(size_t j = 0; j < M; j++) pA[i][j] += (i-j) * (i-j);
}
}
int main(void)
{
constexpr int M = 10;
constexpr int N = 12;
int A[N][M];
for(size_t i = 0; i < N; i++)
{
for(size_t j = 0; j < M; j++) A[i][j] = -(i-j) * (i-j);
}
test(N, M, (int*)A);
for(size_t i = 0; i < N; i++)
{
for(size_t j = 0; j < M; j++) printf("%d ", A[i][j]); // если все правильно, то должны напечататься нули
}
printf("\n");
return 0;
}
Цитата
smalcom [ ~ ]$ g++ -std=gnu++11 1.cpp -o prog
smalcom [ ~ ]$ ./prog
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
доказательство порядочности программы )))
Цитата
smalcom [ ~ ]$ valgrind --leak-check=full ./prog
==5138== Memcheck, a memory error detector
==5138== Copyright © 2002-2013, and GNU GPL'd, by Julian Seward et al.
==5138== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==5138== Command: ./prog
==5138==
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
==5138==
==5138== HEAP SUMMARY:
==5138== in use at exit: 72,704 bytes in 1 blocks
==5138== total heap usage: 1 allocs, 0 frees, 72,704 bytes allocated
==5138==
==5138== LEAK SUMMARY:
==5138== definitely lost: 0 bytes in 0 blocks
==5138== indirectly lost: 0 bytes in 0 blocks
==5138== possibly lost: 0 bytes in 0 blocks
==5138== still reachable: 72,704 bytes in 1 blocks
==5138== suppressed: 0 bytes in 0 blocks
==5138== Reachable blocks (those to which a pointer was found) are not shown.
==5138== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==5138==
==5138== For counts of detected and suppressed errors, rerun with: -v
==5138== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)