Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
447 B
2
Indexable
Never
#include <stdio.h>

int main()
{
    int suma = 0;
    int* px = NULL;
    int x[ 10 ] = { 1, 2, 3, 4, 5 };

    for( px = x; px < &x[ 10 ]; ++px )
    {
        printf("Wartość wskaźnika ptr: %p\n", px);
        suma += *px;
    }
    printf("\n suma = %8d", suma);

    suma = 0;
    for( int i = 0; i < 10; ++i )
    {
        suma += *( x + i ); // x[ i ]
    }
    printf("\n suma = %8d", suma);

    return 0;
}

Leave a Comment