Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'ve been trying to compile and link these 2 cpp files plus I have a header fil

ID: 3725150 • Letter: I

Question

I've been trying to compile and link these 2 cpp files plus I have a header file also. For some reason I keep getting this error message and to tell you the truth, I have no idea where the problem is and any search I've done so far shows no answers. Some help would be greatly appreciated. I attached the two source codes.

Undefined symbols for architecture x86_64:

"_edata", referenced from:

_main in lab1a-7fc4d3.o

"_end", referenced from:

_main in lab1a-7fc4d3.o

"_etext", referenced from:

_main in lab1a-7fc4d3.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

#include extern int gcount; void swapper (int & fnum, int &snum;) /in order to perform I/0 */ 3 4 5 /* declaration of the variable gcount* static int cflag=0; int temp; output the addresses of the static local variable of swapper cflag &c; flag); 10 11 printf(" &Cflag; = %8x ", 12 13 * output the addresses of the local variables and parameters of swapper fnum, snum, and temp- printf (" &fnum; = %8x &snum; = %8x &temp; %8x ", &fnum;, &snum; &temp;) ; , 15 16 17 18 19Y 20 21 cflag+ if (fnum> snum) /I to count the number of times this function has been called so far gcount ++; temp = fnum; fnum = snum; snum = temp ; 23 24 25 26 printf (" so far, function swapper has been called : times" , cflag); 28 29 30 31 32 int express (int num1, int num2) output the addresses of the parameters of function express, num1 and num2 &num2;); printf(" express: &num1-; return (2 num1 -num2); %8x express: &num2; %8x", &nun1;,

Explanation / Answer

extern keyword doesn't create any memory... So, the variable is unknown to print.

the main purpose of extern is wherever you assigned value in program, it automatically assigned wherever you print, it takes final value.

Example: without extern

#include<stdio.h>

int main(){

printf("%d", n);

}

int n =10;

output: unknown error

with extern:

#include<stdio.h>

extern int a;

int main(){

printf("%d", a);

}

int a = 10;

output: 10

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote