Home › Forums › C Programming › Linker Errors, i do believe i need help
- This topic has 5 replies, 3 voices, and was last updated 15 years, 9 months ago by JonathaThurston.
- AuthorPosts
- March 15, 2009 at 7:37 pm #2181AnnelieSchoenheParticipant
Okay, I’m studying C in order to code homebrew for the PSP kernal 3.XX and higher. (No Kxploit). Thing is, i’m starting out creating regular computer programs first. But wait, the tutorial i’m using doesn’t explain errors. So here I am, staring at two linker errors regarding functions. I’ve seperated the functions from the main function so i can work on them seperately in differn’t source files. I’m a new person to this coding business, so if you need my code or such, i’ll gladly post up here. Its nothing no one can do. ^_^
- March 16, 2009 at 8:50 pm #3524GWILouisaxwzklaParticipant
Would help to post your code and errors. Make sure that the file your including has the correct “include” syntax , like:
1234<br /><br />#include "c:myfile.cpp"<br />and make sure that your function prototypes and declarations match perfectly or the linker will not associate the two correctly….
- March 19, 2009 at 10:15 pm #3525AnnelieSchoenheParticipant
Before i start, i fortunetly was able to fix the Linker errors. I fear i may have more of them later, but when that time comes, i’ll fix them. Now i have new errors.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122//A basic two in one program used for studying functions and arithmatic.<br />//Created by Deathscreton on 5:08 PM 3/20/09<br />#include <stdio.h><br /><br />addition()<br />{ do<br />{<br />char counter,addy,back,exit,yes,no;<br />int count;<br />int a;<br />int b;<br />int sum;<br />count=0;<br />counter='d';<br />addy='g';<br />back='f';<br />exit='k';<br />yes='n';<br />++count;<br /><br />printf("Please enter the first number: n");<br />scanf("%d",&a);<br />printf("You've entered %d, is this correct? Y for yes, n for no.",a);<br />scanf("%c %c",&yes, &no);<br />if (yes=='y')<br />{<br />printf("Please enter the second number: n");<br />scanf("%d",&b);<br />printf("You've entered %d, is this correct? y for yes, n for no.",b);<br />scanf("%c %c",&yes, &no);<br />if (yes=='y')<br />{<br />sum=a+b;<br />printf("The answer of the numbers entered is %d. Would you like to run this again?",sum);<br />scanf("%c %c",&yes, &no);<br />if (yes=='y')<br />{<br />addition();<br />}<br />else (no=='n');<br />{<br />main();}<br />}<br />else (no=='n');<br />{<br />addition();<br />}<br />}<br />}while (count < 48793);<br /><br />}<br /><br /><br /><br />counting()<br />{<br /><br />do<br />{<br />int count;<br />char yes;<br />char no;<br />char exit;<br />exit='e';<br />count=-89898;<br />yes='h';<br />no='b';<br />printf("Press 'x' to exit the counter, press any other key to start. n");<br />scanf("%c",&exit);<br />if (exit=='x')<br />{ break;}<br />do<br />{<br />++count;<br />printf("The counter is now at %d n",count);<br />}while (count < 898989);<br />printf("The final count number is %d n",count);<br />printf("Would you like to run the counter again? y for yes n for no.");<br />scanf("%c %c",&yes,&no);<br />if (yes=='y');<br />{counting();}<br />else (no=='n');<br />{main();}<br />}while (exit=='b');<br />}<br />}<br /><br /><br />int main()<br />{<br />char start;<br />char counter;<br />char addy;<br />char back;<br />char exit;<br />char yes;<br />char no;<br />int count;<br />int a;<br />int b;<br />int sum;<br />count=-897989;<br />counter='d';<br />addy='g';<br />back='f';<br />exit='k';<br />yes='n';<br />start='o';<br /><br />printf("Welcome to the Basic two in one program created by Deathscreton(a small time coder on his way to PSP homebrew.) n");<br />printf("This Basic two-in-one program contains a primative addition calculator and a high sped up counter from the numeric number -897989 to +48793. n");<br />printf("You will now be prompted to chose the Addition calculator, or the counter. n");<br />printf("For the addition calculator, press a then enter. For the counter, press c then enter. To exit the program, press x then enter. n");<br />scanf("%c %c",&addy,&counter,&exit);<br />if (addy=='a')<br />{addition();}<br />else (counter=='c');<br />{counting();}<br />else (exit=='x')<br />{break;}<br />return 0;}<br />Thats the code, now here are the current errors:
In function ‘addition’:
Line 49 :’count’ undeclared (first use in this function
(Each undeclated identifier is reported only once
for each function it appears in.)
In function ‘counting’:
Line 82: syntax error before “else”
Line 84: ‘exit’ undeclared(first use in this function)
At top level:
Line 86: syntax error before ‘}’ token
In function ‘main’:
Line 119: syntax error before “else”
Those are the errors. I don’t understand why the pop up. I fix one, and another two take that one’s place. What in the world is going on? - March 20, 2009 at 4:28 am #3526JonathaThurstonParticipant
When your using an if/else statement you can’t give a condition to the else instead you should use else if(condition).
1234567891011<br />if(i != x){<br />...<br />}<br />else if(i == j){<br />...<br />}<br />else(){<br />...<br />}<br />Also your calling int count at the start of the function and again at the start of your do/while loop.
- March 20, 2009 at 3:54 pm #3527AnnelieSchoenheParticipant
Wait, so the first else after the initial if should be if followed by a else Which is the second else in the statement right?
123456789101112if(exit=3)<br />{.....<br />}<br /><br />//This is where i'm confused<br />//This is where the else if should be first right? Then an else should be right after it?<br />else if(exit==23){<br />...<br />}<br />else(exit==46){<br />...<br />}And even after that, i still recive errors up the ass. I built this code form the floor. How did these codes slip past?
- March 20, 2009 at 7:36 pm #3528JonathaThurstonParticipant
Here read http://www.cprogramming.com/tutorial/c/lesson2.html for information on if/else statments, and your if should be
1if(exit == 3) not if(exit = 3e)as what you did assigns 3 to exit.
- AuthorPosts
- The forum ‘C Programming’ is closed to new topics and replies.