+ 4

May I have some help please? [SOLVED]

I am trying to join a site for intermediate programming. It asks for a solution to a problem. I do not want a answer. I would rather know where to find it. Here is the code: https://code.sololearn.com/cxw5gcTb1VZv/?ref=app

22nd Apr 2017, 2:45 AM
Manual
Manual - avatar
31 Answers
+ 16
@Manual Ah, you are missing the fundamental of CodeWars. Main is defined and run as the program (not the code you wrote). You write a function which is called in the main of the program that you don't write. Does this make sense why it says it was already defined?
22nd Apr 2017, 3:07 AM
J.G.
J.G. - avatar
+ 13
#include <iostream> using namespace std; int multiply(int a, int b) { return a * b; } int main(){ multiply(7,7); } you should only include the return keyword. I have solved this in code wars.
22nd Apr 2017, 3:16 AM
Mr.Robot
Mr.Robot - avatar
+ 9
Guys I also wanna join Codewars but when i enter the code its showing this error -isystem /runner/frameworks/cpp/ error: conflicting types for 'main' int main(int argc, const char *argv[]) ^ note: previous definition is here int main(){ ^ 1 error generated.
1st Feb 2018, 3:05 PM
Game'OBot
Game'OBot - avatar
+ 8
I was using the microsoft and c++ reference to try to define cout for a while. Thanks again for the help
22nd Apr 2017, 3:22 AM
Manual
Manual - avatar
+ 7
#include <iostream> #include <string> #include <cstdlib> using namespace std; int function(std::string str); int multiply(int a, int b){ return a * b; } int main(){ cout<<multiply(7,8); return 0; } With this error: -isystem /runner/frameworks/cpp error: conflicting types for 'main' int main(int argc, const char *argv[]) ^ note: previous definition is here int main(){ ^ 1 error generated.
22nd Apr 2017, 3:10 AM
Manual
Manual - avatar
+ 7
Wait you got it?
22nd Apr 2017, 3:12 AM
Manual
Manual - avatar
+ 7
you have the answer. you have just extended upon it too much
22nd Apr 2017, 3:13 AM
jay
jay - avatar
+ 7
haha I got it. @Jay @J.G @Mr.Robot Thanks I did as J.G said and only included the function. I understand now.
22nd Apr 2017, 3:17 AM
Manual
Manual - avatar
+ 6
One more thing when I used "main(){}" I get an error saying "main(){}" was previously defined
22nd Apr 2017, 3:01 AM
Manual
Manual - avatar
+ 6
yeah. trying too hard
22nd Apr 2017, 3:11 AM
jay
jay - avatar
+ 6
just complete the function. thats all
22nd Apr 2017, 3:11 AM
jay
jay - avatar
+ 6
yep
22nd Apr 2017, 3:12 AM
jay
jay - avatar
+ 6
dont worry about main. its assumed it works fine. only the multiply function is broken and that is all you need to fix
22nd Apr 2017, 3:17 AM
jay
jay - avatar
+ 6
yeah. it wasnt worded great (says me with my great english display)
22nd Apr 2017, 3:23 AM
jay
jay - avatar
+ 5
lol... indeed there is a problem with that code. i would be looking at the placement of the functions if I were you (as a start)
22nd Apr 2017, 2:50 AM
jay
jay - avatar
+ 5
mmhmm save what you've done so far as I can only see the multiply function inside main version
22nd Apr 2017, 2:53 AM
jay
jay - avatar
+ 5
I have tried to find out how to get cout from ostream. I was not able to do it. I tried std::cout<< That failed as well.
22nd Apr 2017, 2:54 AM
Manual
Manual - avatar
+ 5
it is still missing something
22nd Apr 2017, 2:59 AM
jay
jay - avatar
+ 5
return 0 maybe
22nd Apr 2017, 2:59 AM
jay
jay - avatar
+ 5
u need another return inside main. it returns a value to the os. what you have in codeplayground is exactly what u have typed in codewars?
22nd Apr 2017, 3:04 AM
jay
jay - avatar