We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
In my project I have two files. as follows File A int x; main() { x=2; } File B extern int x; { x=4; } When I compile both files independatly, there is no error. When I link both modules, there is no error. But when I execute this program, I am unable to assign x = 4. Always the value of x remains 2. But in file A I can assign any value to x. Why I can not assign any value to x in File B? I am trying this with Keil compiler.
"The expected answer is 4. But I am getting 2." And I am getting 4. What are you using for a debugger? Try using uVision's simulator, add 'x' to a watch window and step through the program.