27 lines
605 B
C
27 lines
605 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include "array.h"
|
|
|
|
/* Prepare usage for 64 bit arrays - adds "Array_uint64" for creat */
|
|
Array(uint64_t, Array_uint64);
|
|
|
|
int main() {
|
|
int n;
|
|
printf("Number of elements to sum: ");
|
|
scanf(" %d", &n);
|
|
/* Create a 64 bit array of 'n' elements */
|
|
creat(Array_uint64, data, &n);
|
|
// printf("vektor.count:%d\n", data.count);
|
|
|
|
for(int i = 0; i < data.count; ++i) {
|
|
scanf(" %d", &n);
|
|
data.v[i] = n;
|
|
}
|
|
n = 0; for(int i = 0; i < data.count; ++i) n += data.v[i];
|
|
printf("Sum: %d\n", n);
|
|
|
|
// RAII releases array here automagicaly!
|
|
return 0;
|
|
}
|