我正在尝试创建一个将结构数组作为参数的函数。到目前为止,这是我代码的一部分:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#define MAXREAD 256
#define MAXARR 64
struct block {
char free;
bool end;
};
void display(struct block *b){
char *p;
printf("|");
for(int i=0; i<MAXARR; i++){
p = &b[i].free;
//printf("%c ", *p);
printf("%c", (*p != '\0' ? '#':'-'));
//printf("%d", p);
if(b[i].end){
//printf("%d\n", i);
printf("|");
}
//printf("%c", blocks[i]->end ? "true":"false");
}
printf("\n");
}
int main(){
char input[MAXREAD];
struct block (*blocks)[MAXARR];
char cmd;
int number;
blocks = malloc(sizeof(struct block));
char *a;
//int *m;
for(int i=0; i<MAXARR; i++){
blocks[i]->free …Run Code Online (Sandbox Code Playgroud)