Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8687227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:04:09+00:00 2026-06-12T23:04:09+00:00

I haven’t worked with C in ages and as such I’ve forgotten an embarrassing

  • 0

I haven’t worked with C in ages and as such I’ve forgotten an embarrassing amount about how C works. I am trying to create a header, ‘arrayUtils.h’ and a corresponding ‘arrayUtils.c’ where I define the prototyped functions. Then I am trying to call one of these functions in a second .c file

Header Contents:

#define _OUT_OF_RANGE_ = NAN

#ifndef INT_ALLOCATE_H
#define INT_ALLOCATE_H
int * allocIntArray(const int size);
#endif

#ifndef INT_ACCESS_H
#define INT_ACCESS_H
int accessIntArray(const int index, const int * array, const bool checked);
#endif

#ifndef INT_FREE_H
#define INT_FREE_H
int freeIntArray(int * array);
#endif

Source for header:

/* Allocates an array of integers equal to length size
 * Args: int size: length of the array
 * Return: Allocated array
 */
int * allocIntArray(const int size){
    /*Assert that size of array is greater than zero*/
    if(size <= 0){
        return(-1);
    }
    else{
        return((int*)malloc(size*sizeof(int)));
    }
}
/* Returns the value of the array 
 * Args: int    index:   position in the array to access
 *       int  * array:   array to access
 *       bool   checked: if the access should be checked or not
 * Returns: integer at position index
 */
int accessIntArray(const int index, const int * array, const bool checked){
    /*unchecked access*/
    if(!checked){
        return(array[index]);
    }
    /*checked access*/
    else{
        if(index <= 0){
            return(_OUT_OF_RANGE_)
        }
        double size = (double)sizeof(array)/(double)sizeof(int)
        if(index => (int)size){
            return(_OUT_OF_RANGE_)
        }
        else{
            return(array[index])
        }
    }
}

/* Frees the allocated array 
 * Args: int * array: the array to free
 * Returns: 0 on successful completion
 */
int freeIntArray(int * array){
    free(array);
    return(0);
}

Then calling in a second source file:

#include "arrayUtil.h"
int main(){
    int * array = allocIntArray(20);
    return(0);
}

When I compile with:

gcc utilTest.c

I get this error:

arrayUtils.h:10: error: syntax error before “checked”

Initially I was using “bool checked” in accessIntArray, and got the same error but with bool instead of checked.

Sorry if this isn’t a specific question but I’m pretty lost here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:04:10+00:00Added an answer on June 12, 2026 at 11:04 pm

    bool is not a standard type in C. The C99 language standard added the new type _Bool for a boolean data type, as well as the header file <stdbool.h> which defines bool, true, and false to map to _Bool, (_Bool)1, and (_Bool)0 respectively.

    If you’re compiling using a C99 compiler, just be sure to #include <stdbool.h> before using the bool keyword. If not, define them yourselves, e.g.:

    typedef unsigned char bool;  // or 'int', whichever you prefer
    #define true ((bool)1)
    #define false ((bool)0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Haven't seen anything about it here but it seems to solve one of the
I haven't designed a website for about 3 years now, so I am quite
Basically, what I'm trying to create is a page of div tags, each has
Haven't done as much of Javascript as I should have done. I am trying
I haven't found information about this anywhere. Is there a minimal required length for
Haven't seen anything, but I have seen that you can create albums in the
I haven't seen easy examples about rotaion around a specified point. I tried something
Haven't touched Ruby for ages so this really puzzled me. Started up irb. Then
Haven't found anything useful about this on the internet. I'm using my Windows 7
I haven't fully understood how qtdecomp works... I = [1 1 1 1 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.