...
Code Block | ||||
---|---|---|---|---|
| ||||
static const size_t#include <stddef.h> #define COLS = 5; static const size_t #define ROWS = 7; static int matrix[ROWS][COLS]; void init_matrix(int x) { for (size_t i = 0; i < COLS; i++) { for (size_t j = 0; j < ROWS; j++) { matrix[i][j] = x; } } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
static const size_t#include <stddef.h> #define COLS = 5; static const size_t #define ROWS = 7; static int matrix[ROWS][COLS]; void init_matrix(int x) { for (size_t i = 0; i < ROWS; i++) { for (size_t j = 0; j < COLS; j++) { matrix[i][j] = x; } } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <string.h>
#include <stdlib.h>
char* init_block(size_t block_size, size_t offset,
char *data, size_t data_size) {
char* buffer = malloc(block_size);
if (data_size > block_size || block_size - data_size > offset) {
/* data won't fit in buffer, handle error */
}
memcpy(buffer + offset, data, data_size);
return buffer;
} |
...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <string.h>
#include <stdlib.h>
char* init_block(size_t block_size, size_t offset,
char* data, size_t data_size) {
char* buffer = malloc(block_size);
if (NULL == buffer) {
/* handle error */
}
if (data_size > block_size || block_size - data_size > offset) {
/* data won't fit in buffer, handle error */
}
memcpy( buffer + offset, data, data_size);
return buffer;
}
|
...