+ 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
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?
+ 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.
+ 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.
+ 8
I was using the microsoft and c++ reference to try to define cout for a while.
Thanks again for the help
+ 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.
+ 7
Wait you got it?
+ 7
you have the answer. you have just extended upon it too much
+ 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.
+ 6
One more thing when I used "main(){}"
I get an error saying "main(){}" was previously defined
+ 6
yeah. trying too hard
+ 6
just complete the function. thats all
+ 6
yep
+ 6
dont worry about main. its assumed it works fine. only the multiply function is broken and that is all you need to fix
+ 6
yeah. it wasnt worded great (says me with my great english display)
+ 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)
+ 5
mmhmm save what you've done so far as I can only see the multiply function inside main version
+ 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.
+ 5
it is still missing something
+ 5
return 0 maybe
+ 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?