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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:38:26+00:00 2026-05-31T05:38:26+00:00

I have these files test1.h extern int value; void inc_value(); int print_value(); test1.c #include

  • 0

I have these files

test1.h

extern int value;
void inc_value();
int print_value();

test1.c

#include "test1.h"

int value=0;
void inc_value() 
{

printf("inc value from test3.c = %d\n", value++); 
}

int print_value() 
{

    printf(" value in test1.c  = %d\n", value);
    return value;
}

test3.c

# include "test1.h"

main()
{

inc_value();

}  

test4.c

# include <stdio.h>
#include "test1.h"

main()

{
    printf("value from test4 = %d\n", print_value());
}  

I’m updating variable “value” from test3.c and trying to read it from test4.c. However test3.c is unable to update the “value” that is declared in test1.h and defined in test1.c

What point am I missing 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-05-31T05:38:28+00:00Added an answer on May 31, 2026 at 5:38 am

    This will never work.

    You can’t use an external variable from two different programs and magically expect it to work. It’s just … wrong. Each program runs in its own address space, and doesn’t know anything about any other process’ address spaces. There are techniques for doing this (look up interprocess communucation), but that’s a whole different area.

    The way extern works is that it allows you to access a variable defined in a different C file within the same program.

    You seem to be mis-understanding at a quite fundamental level how the programs you are writing work and execute, since you expect this to work. I recommend reading up more on how C works, and also perhaps a bit on how operating systems host programs in order to run them.

    One way of sharing information between programs like you describe is to store the data in a file, which is written by one program (the one that runs first) and read by the other, but that is quite tricky to get right, too.

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

Sidebar

Related Questions

Say I have this url: http://site.example/dir/ In this folder I have these files: test.ascx.cs
I have a folder with these files: alongfilename1.txt <--- created first alongfilename3.txt <--- created
I have 4 files sorted alphabetically, A, B, C, and D. These files contain
I have a python project with this directory structure and these files: /home/project_root |---__init__.py
I have a dozen configuration properties files for the ant script. These files are
I have an index.html and global.css files. When I open these files at Coda,
I have a few log files like these: /var/log/pureftpd.log /var/log/pureftpd.log-20100328 /var/log/pureftpd.log-20100322 Is it possible
I have a class split across two files. One of these is generated, the
I have a website where users can upload their files; these are stored on
I have written a service that monitors a file drop location for files from

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.