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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:27:06+00:00 2026-06-05T21:27:06+00:00

I have a C structures in two different machines – server and clients. For

  • 0

I have a C structures in two different machines – server and clients. For example:

struct account {
   int account_number;
   char *first_name;
   char *last_name;
   float balance;
};

My question is what are the possible ways to replicate the data between the machines? Maybe I can try to convert the data in XML and copy it? Or I can use arrays?

  • 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-05T21:27:08+00:00Added an answer on June 5, 2026 at 9:27 pm

    The simplest, most lightweight solution – if you have a connection open between the two machines in the form of a FILE* – may be to transmit with fprintf on one end, and decode with fscanf on the other.

    protocol.h:

    typedef struct _packet packet_t;
    
    struct _packet {
      int account_number;
      char *first_name;
      char *last_name;
      float balance;
    };
    
    static const char packet_fmt[]=" acct: %d fname: %s sname: %s balance: %f";
    

    sender:

      ...
      printf(packet_fmt, acct, "Greg", "Benison", bal);
      ...
    

    listener:

    ...
    int n_read = fscanf(fin, packet_fmt, &acct, fname, sname, &balance);
    
    if (n_read == 4)
      printf("Received balance update for %s %s: %f\n", fname, sname, balance);
    ...
    

    That may suffice for your four-field struct, but if you anticipate its structure changing or growing significantly it may make sense to pursue XML, JSON, or some other more formal encoding.

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

Sidebar

Related Questions

Essentially I have two different flat files Credit & Account with different record structures.
Hi I have two text files that each contain different information about certain structures.The
I have two similar[all attributes are same.] structures within different namespaces. Now when i
I have an object which will be stored in two different data structures. I
I have data spread over two MySQL tables with different structures. One table has
In my code base I find that two modules have structures with the same
I have some HTML that I need to toggle between two structures - one
I have these two data structures that I continually find myself choosing between when
Say I have a database called Poll and have these two table structures. poll
I have two tables with the following (simplified) structures: table "Factors" which holds data

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.