Need help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Need help

im using code:block at pages. //f.cpp file #include<iostream> int count; extern void write_extern(); int main() { count =5; write_extern(); return (0); } error:1.undefined reference write_extern() 2.id retuened 1 exit status. //f1.cpp #include<iostream> extern int count; using namespace std; void write_extern(void) { cout<<"cout is:"<<cout<<endl; } error:1.undefined count 2.id returned 1 exit status 3.undefined WinMain@l6 i tried to fix with adding #include"f1.cpp" right at the bottom of <iostream> in f.cpp file. f.cpp running n output is 5. then, at file f1.cpp i do the same with adding #include"f.cpp" n not compiling cos it has many error. like keep going to list. i back to my f.cpp file n its still can be compiled n running. how to run both file? thank you so much in advance

5th Dec 2018, 12:42 AM
Upar24
Upar24 - avatar
8 Answers
+ 2
Hi, Upar! From the beginning. 1. f.cpp : extern must be deleted ( because prototype is sufficiently), 2. f1.cpp : "cout is:" << count ?(not cout)
5th Dec 2018, 4:37 AM
stamb
stamb - avatar
+ 1
Not understand you answer. Did you deleted extern? More. 1. f.cpp : Add, to define count with initialization (e.g. 0) together. 2. Avoid #include "f1.cpp".
5th Dec 2018, 3:42 PM
stamb
stamb - avatar
+ 1
Excuse me! The night was. Continue. I saw the link. By the way, int foo() and void foo() - different therein ! So. 1. f.cpp: extern(line 3) - delete! 2. f1.cpp: must be - void write_extern()...//empty brackets
6th Dec 2018, 3:56 AM
stamb
stamb - avatar
0
1. i deleted n try to compile it then it shows error. 2. fixed.
5th Dec 2018, 2:40 PM
Upar24
Upar24 - avatar
0
//f.cpp 1.#include<iostream> 2.int count = 0; 3. extern void write_extern(); 4.int main(){ 5.count=5; 6.write_extern(); 7.return (0); 8.} 3 errors. 1.undefined count. 2.undefined to winMain@16. 3.id returned 1 exit status. //f1.cpp 1.#include<iostream> 2.extern int count; 3.using namespace std; 4.void write_extern(void){ 5.cout<<"Count is:"<<count<<endl; 6.} 3 errors. 1. undefined count 2. undefined WinMain@16. 3. id returned 1 exit status.
5th Dec 2018, 4:20 PM
Upar24
Upar24 - avatar
0
sorry at f.cpp has 3 errors which 1. undefined write_extern() instead of undefined count.
5th Dec 2018, 4:24 PM
Upar24
Upar24 - avatar
5th Dec 2018, 4:25 PM
Upar24
Upar24 - avatar
0
ill try at night when i get home n ik the diff between int foo() and void foo() bout their type of return n btw thanks for ur help ill b glad if u dont mind till those files running.
7th Dec 2018, 2:02 AM
Upar24
Upar24 - avatar