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 8799245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:16:27+00:00 2026-06-14T00:16:27+00:00

LMlib.h #ifndef LMlib_H #define LMlib_H #endif #define MAX_IP_LENGTH 15 #define MAX_TABLE_ROWS 255 struct ForwardingTableRow

  • 0

LMlib.h

#ifndef LMlib_H
#define LMlib_H
#endif

#define MAX_IP_LENGTH 15         
#define MAX_TABLE_ROWS 255

struct ForwardingTableRow
{
        char address[MAX_IP_LENGTH];
        int subnetMask;
        int interface;
};

typedef struct ForwardingTableRow ForwardingTableRow;

LMlib.c

#include <stdio.h>
#include <math.h>
#include "LMlib.h"

void ReadForwardingTable(FILE* f,ForwardingTableRow * table)
{
        int i;
        for(i=0;i<MAX_TABLE_ROWS;i++)
        {
                fscanf(f,"%s %d %d",&table.address[i],&table.subnetMask[i],&table.interface[i]);
        }


}

Complier command:

cc LMlib.c LMlib.h main.c -lm

Error:

LMlib.c: In function ‘ReadForwardingTable’:
LMlib.c:11:27: error: request for member ‘address’ in something not a structure or union
LMlib.c:11:45: error: request for member ‘subnetMask’ in something not a structure or union
LMlib.c:11:66: error: request for member ‘interface’ in something not a structure or union

What have I done wrong?

  • 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-14T00:16:28+00:00Added an answer on June 14, 2026 at 12:16 am

    You have three problems: The first is that you don’t use the array indexing properly. It’s the table variable that is the array, not the structure member:

    fscanf(f, "%s %d %d",
        table[i].address,
        &table[i].subnetMask,
        &table[i].interface);
    

    The second problem is unrelated to your question, but may lead to trouble in the future. It’s the include guard you have. The #endif should be at the end of the file, otherwise you only protect the single #define and nothing else.

    The third, and most serious, problem is that you have one character to little in the address field. The maximum length of an IP-address is 15, which is correct, but if you want to treat it as a string you need space for the string terminator as well. Declare it as

    address[MAX_IP_LENGTH + 1];
    

    and it should be okay.

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

Sidebar

Related Questions

I have the file blah.c containing: #include <gobject-introspection-1.0/girepository.h> int main(int argc,char **argv) { GIRepository
The linux kernel (and various other projects including git) have very nice makefiles that
Whatever I try to compile in Cygwin I get the following output: checking for
This is wholy mysterious to me. I'm using g++ on ubuntu, and this is
I am using Qt Creator and have a Qt GUI project that depends on
Apologize because for the moment I don't have the environment to experiment and sort
I am getting this error while running a hadoop pipes program. The program compiles
For XSLT processing, I am trying to use XML::LibXSLT. I am having ActiveState Perl
I have a main function, but when tcc goes to link everything together, it
I am trying to make a static binary on Subsurface on MacOSX, so that

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.