Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C99 doesn't allow initializers in if-conditions, so this does not compile.
// C99 doesn't allow initializers in if-conditions, so this does not compile. #include <assert.h> #include <stdio.h> #include <stdlib.h> static unsigned long long *fibonacci(const size_t length) { assert(length > 1); if (unsigned long long *const fib = calloc(length, sizeof *fib)) { fib[0] = 0; fib[1] = 1; for (size_t i = 2; i != length; ++i) fib[i] = fib[i - 2] + fib[i - 1]; return fib; } return NULL; } int main(int argc, char **argv) { (void)argc; static const size_t length = 94; if (unsigned long long *const fib = fibonacci(length)) { printf("[ "); for (size_t i = 0; i != length; ++i) printf("%llu ", fib[i]); printf("]\n"); free(fib); exit(EXIT_SUCCESS); } fprintf(stderr, "%s: error: out of memory\n", argv[0]); return EXIT_FAILURE; }
run
|
edit
|
history
|
help
0
Bucles: Ver si un número es primo
Cvičenie -č.5-UDP
lab7OOP 0.1
cv8_5
Cuadrado asteriscos solido
Herout (67) - 8
Sin(x) in C Teylor
Punteros: dame tres valores
scanf() and printf()
Ashar