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

  • SEARCH
  • Home
  • 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 6594649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:50:18+00:00 2026-05-25T17:50:18+00:00

I wrote this header file for a another main program. This file declares a

  • 0

I wrote this header file for a another main program. This file declares a struct_buffer struct that is used by the main function (somewhere else).

What I am trying to do is that when someone initialises a buffer with the buffer_init function, a pointer to the buffer is returned. The buffer would contain, an array of pointers, the current number of pointer in the buffer(size), and the file-pointer to a file to which the pointers stored in the buffer will be dumped.

The main program will call the add_to_buffer() function to add pointers to the buffer. This in turn calls the buffer_dump() function to dump the pointers in a file specified by the buffer->fp. At the end, I will call buffer_close() to close the file. However compiling it gives me several errors that I am unable to understand and get rid of.

The following is a code of header file in C, that I am trying to compile and it is giving me errors that I can’t understand.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_PTRS 1000

struct struct_buffer
{
    int size;
    File *fp;
    unsigned long long ptrs[MAX_PTRS];
};

//The struct_buffer contains the size which is the number of pointers in ptrs, fp is the file pointer to the file that buffer will write 
struct struct_buffer*
buffer_init(char *name)
{
    struct struct_buffer *buf = malloc(sizeof(struct struct_buffer));
    buf->size = 0;
    buf->fp = fopen(name,"w");
    return buf;
}

//This function dumps the ptrs to the file.
void
buffer_dump (struct struct_buffer *buf)
{
  int ctr=0;
  for(ctr=0; ctr < buf->size ; ctr++)
  {
    fprintf(buf->fp, "%llx\n",buf->ptrs[ctr]);
  }
}

//this function adds a pointer to the buffer
void
add_to_buffer (struct struct_buffer *buf, void *ptr)
{
 if(buf->size >= MAX_PTRS)
 {
  buffer_dump(buf);
  buf->size=0;
 }
 buf->ptrs[(buf->size)++] = (unsigned long long)ptr;
}

//this functions closes the file pointer
void
buffer_close (struct struct_buffer *buf)
{
 fclose(buf->fp);
}                          

The above code on compilation gives me the following errors. I could not understand the problem. Please explain to me what the trouble is.

buffer.h:10: error: expected specifier-qualifier-list before 'File'
buffer.h: In function 'buffer_init':
buffer.h:19: error: 'struct struct_buffer' has no member named 'fp'
buffer.h: In function 'buffer_dump':
buffer.h:29: error: 'struct struct_buffer' has no member named 'fp'
buffer.h:29: error: 'struct struct_buffer' has no member named 'ptrs'
buffer.h: In function 'add_to_buffer':
buffer.h:40: error: 'struct struct_buffer' has no member named 'ptrs'
buffer.h: In function 'buffer_close':
buffer.h:46: error: 'struct struct_buffer' has no member named 'fp'
  • 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-05-25T17:50:18+00:00Added an answer on May 25, 2026 at 5:50 pm

    File is not defined. The correct type you are looking for is FILE.

    struct struct_buffer
    {
        int size;
        FILE *fp; // <---------
        unsigned long long ptrs[MAX_PTRS];
    };
    

    The rest of your errors appear to be a product of this error, so this should be your only fix.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this header file, zeeheader.h, and I wrote some classes in it, I'm
I wrote this function that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000" .
I wrote this function but can't get on the problem that gives me 'segmentation
I wrote this code I have these errors Cannot implicitly convert type x.Program.TreeNode' to
I wrote this function for filling closed loop, pixvali is declared globally to store
I wrote this function to get the unread count of google reader items. function
I wrote this script which counts occurrences of particular pattern in a given file.
I wrote this function to get a pseudo random float between 0 .. 1
I wrote this tiny code: #include <stdio.h> int main() { size_t temp; temp =
In my project I have a schema file and utility that I wrote to

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.