Ask coding questions

← Back to all posts
1
i cant figure out the errors in this C++ code
AbdullahAbumaze (0)

#include <stdio>

int main (void)

{

printf('We are to learn correct');

printf('C language here' );

return 0;

}

Answered by ArchieMaclean (520) [earned 5 cycles]
View Answer
Commentshotnewtop
3
ArchieMaclean (520)

There are a few bugs.
1) You are in a C# repl, but what you have actually written is C.
2) stdio should be replaced with stdio.h
3) You don't need to specify void if the method takes no arguments.
4) Strings should have double quotes around them - single quotes are for chars.

So, the fixed code is (in a C repl):

#include <stdio.h>

int main ()

{

printf("We are to learn correct");

printf("C language here");

return 0;

}

Repl link here.
Please mark this as the answer if it solved your problem :)