Below is the error that it is giving me and my code:
workspace.c: In function 'main':
workspace.c:38: error: subscripted value is neither array nor pointer
workspace.c:39: error: subscripted value is neither array nor pointer
any input would be greatly appreciated! and thank you for you time.
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <dirent.h>
#include <sys/time.h>
#include <fcntl.h>
#define n 4
struct process
{
struct segment{
struct page
{
int pid;
int p[4];
}pages;
}segments;
};
struct process processes[3];
struct page pages[n];
struct segment segments[n];
int main()
{
int a, b, c;
int k = 0;
for(a = 0; a < 3; a++)
{
for(b = 0; b < 4; b++)
{
for(c = 0; c < 4; c++)
{
k++;
processes[a].segments[b].pages[c].pid = k;
printf("Segment: %d, Page: %d, PID: %d\n",a,b,processes[a].segments[b].pages[c].pid);
}
}
}
return 0;
}
#defineing something as short as n is a bit dangerous, as it could lead to substitutions you didn't intend.Ctradition is to use all upper case and something descriptive, such as#define MAX_PAGES 4