Questions tagged [main]
The main tag has no usage guidance.
11 questions
0
votes
1
answer
86
views
CS50 Pset1 credit card
Very small question: Most probably you have seen the original text of the problem, so I'll just paste here the small extract:
"So that we can automate some tests of your code, we ask that your ...
0
votes
0
answers
1k
views
speller.c:217:5: error: redefinition of 'main' int main
I actually received two error messages:
speller.c:217:5: error: redefinition of 'main'
int main(int argc, char *argv[])
^
speller.c:20:5: note: previous definition is here
int main(int argc, ...
0
votes
3
answers
81
views
factorial code;why does main function not return answer?
In the following code, my last statement in main function is return fact(n) does not work.
But if I substitute it with printf ("Factorial of %d = %d\n", n, fact(n));
it works
My question is if main ...
0
votes
1
answer
1k
views
Use of functions and variable declarations outside main() on pset1 greedy
I have completed greedy from pset1 and I still doubts about the variable declarations and the function position.
What is the difference if they are declared inside or outside the main function?
#...
0
votes
1
answer
2k
views
Difference between return 0; and return (0);
I am working through the chapters on 'absolute beginners guide to c' Sometimes for the main function return statement he uses:
return 0;
and other times
return (0);
I am assuming there is no ...
0
votes
1
answer
81
views
space between function name and variables e.g. int main (void)
I checked the style guide
https://manual.cs50.net/style/
and the C99 Standard
https://en.wikipedia.org/wiki/C99
And neither explicitly states the best format but both implicitly write out main as so
...
2
votes
2
answers
95
views
Could we declare the main function as "main () {}" rather than "int main (void) {}"?
In the examples in week 1, we declare the main function as follows:
int main (void)
{
// code
}
Why do we use int? Is it wrong to use the following instead?
main ()
{
// code
}
0
votes
1
answer
267
views
Breakout main function will not move the paddle or the ball
I have created the paddle, ball, and bricks, but when I write the code to make paddle move nothing happens. I tried to write the ball movement code also but that doesn't work either. I think I am ...
0
votes
1
answer
3k
views
pset3 helpers c, linear search
bool search(int value, int values[], int n)
{
// TODO: implement a searching algorithm
for (int i = 0; i < n; i++)
{
if(values[i] == value)
{
return i;
...
0
votes
2
answers
3k
views
Is a Semicolon Required After main()'s Signature?
When trying to compile my mario.c and greedy.c programs, Clang compiler error messages indicate that a semicolon is needed after int main(void).
The C book that I am using (i.e., C Step by Step by ...
2
votes
1
answer
2k
views
why do we pass arguments to the main function?
I did not understand that ,why do we pass arguments to the main function?
for example in pset3 generate.c main {int argc,string argv[]}.
please explain?