Daniele°
Because default functions type is int
Daniele°
() != (void)
Daniele°
You can pass arguments to () but not to (void)
olli
What is difference between void main() and void main(void)
In C++ foo() function foo with no parameters foo(void) function foo with no parameters In C foo() function foo with an unspecified numbers of parameters foo(void) function foo with no paramters
Dima
lol this is very old C
Dima
in new C its ok
olli
Valid in C89 and still in C11
Dima
maybe I got mistaken, but I saw otherwise somewhere
Dima
lol my github project
Dima
probably headers
Dima
perhaps anyone would like to check https://github.com/luckyycode/neko-webframework/
olli
"C11" (n1570) **6.7.6.3 Function declarators (including prototypes) ** 10 The special case of an unnamed parameter of type void as the only item in the list specifies that the function has no parameters. 14 An identifier list declares only the identifiers of the parameters of the function. An empty list in a function declarator that is part of a definition of that function specifies that the function has no parameters. The empty list in a function declarator that is not part of a definition of that function specifies that no information about the number or types of the parameters is supplied. "C++17" (n4659) **11.3.5 Functions** 4 […] If the parameter-declaration-clause is empty, the function takes no arguments. A parameter list consisting of a single unnamed parameter of non-dependent type void is equivalent to an empty parameter list. […]
Dima
¯\_(ツ)_/¯ docs for the win
ENTP
Please is there anyway to write a code to print the prime numbers from 1 to 1000?
Roxifλsz 🇱🇹
Please is there anyway to write a code to print the prime numbers from 1 to 1000?
Just count prime numbers in a loop which terminates when they reach 1000
ENTP
You first need the algorithm to calculate the prime numbers before printing with for loop
Roxifλsz 🇱🇹
You first need the algorithm to calculate the prime numbers before printing with for loop
That algorithm is very common, you can find it very easily trough google
olli
Another maybe easier solution would be to use the "Sieve of Erastosthenes" https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
ENTP
That algorithm is very common, you can find it very easily trough google
Before I ask anything here, I do a lot of research... I didn't find anything useful on google or bing
Dave
Do u want c++ code
Dima
i like it that way
Manuele
i like it that way
it's a library right?
Dima
yeah
Dave
int i = 0; while(i<=1000) { cout<<i<<endl; i++; i=i+1; } return 0;
Anonymous
:o
Dave
It is the source code that display u even numbers 0-1000
ENTP
I didn't ask for even number. Prime numbers.
ENTP
Easy way to get even numbers is using %
ENTP
If (n % 2 ==0)
Jussi
I didn't ask for even number. Prime numbers.
lazy algo is to try to check the remainder of every number from 0 to half of the current number
Jussi
from 2 to half* of course
ENTP
Okay
Justin
So the main reason I've been playing with C off and on is to write an NES game without having to deal with assembly. Anybody have experience with the cc65 compiler? Or know a NES dev chat? Or both, even? Cheers!
Talula
No
So you're saying ()! = (void) but you can pass arguments to () but you can't get them but you're not passing arguments to (void) and you can't get them, I get your point about main() not equal to void main(void) because you can return int but main(void) != main() doesn't make sense to me.
olli
So you're saying ()! = (void) but you can pass arguments to () but you can't get them but you're not passing arguments to (void) and you can't get them, I get your point about main() not equal to void main(void) because you can return int but main(void) != main() doesn't make sense to me.
This applies for function declarations In C++ foo(); function foo with no parameters foo(void); function foo with no parameters In C foo(); function foo with an unspecified numbers of parameters foo(void); function foo with no paramters This applies for function definitions in C and C++ foo(){} and foo(void){} mean a function with no parameter So when defining the function int main() {} it should be equivalent to int main(void) {} - since it's a definition As example for the unspecified parameters, take the following C code extern void foo(); void qaz() {} void bar() { foo(1, 3); // Valid! foo declared with () qaz(1, 3);. //Invalid! qaz defined as () }
Anonymous
void can’t return any thing
Talula
Yeah you can do it but it has same result, specially if its your main(void) is not called internally.
olli
This, the invalid case, would result in a compile error
Talula
This, the invalid case, would result in a compile error
And other one won't but I can't do anything with it, i.e. same thing, it's void or null or "completely empty"...
Top T : Trollface Was Real
Talula
It's different because compiler thinks so but functionality wise it's same.
olli
Top T : Trollface Was Real
A function with void result type ends either by reaching the end of the function or by executing a return statement with no returned value. The void type may also appear as the sole argument of a function prototype to indicate that the function takes no arguments. Note that despite the name, in all of these situations, the void type serves as a unit type, not as a zero or bottom type (which is sometimes confusingly called the "void type"), even though unlike a real unit type which is a singleton, the void type lacks a way to represent its value and the language does not provide any way to declare an object or represent a value with type void.
olli
And are we talking about the return type or the parameters?
Talula
Are we talking about declarations or definitions?
Neither, we are talking about what can main(void) do that main() can't or doesn't or vise versa, functionality wise it's same...
Talula
And are we talking about the return type or the parameters?
No we are not, I understand that main(void) is actually int main(void) so I agree on that... yes you can return int when the program ends.
Talula
Beause main is called by the OS returning a number is valid.
Talula
But if main is not passed any arguments and doesn't have capability to accept any arguments, if you say void main(void) it's same as void main()
Anonymous
I already know java
good but which one is better?
Khalid
It's affectation: 0 value to variable i
Anonymous
Any one from Germany,Italy?
Anonymous
please replay
AbdumajiD
No
Ride
No
Anonymous
UK, Be, germany, US, canada, itly, greece
Talula
UK, Be, germany, US, canada, itly, greece
What has C/C++ to do with these countries?
Daniele°
So you're saying ()! = (void) but you can pass arguments to () but you can't get them but you're not passing arguments to (void) and you can't get them, I get your point about main() not equal to void main(void) because you can return int but main(void) != main() doesn't make sense to me.
In C, void test() declares a function that takes an unspecified (but not variable) number of parameters (and returns nothing). So all your calls are valid (according to the prototype) in C. In C, use void test(void) to declare a function that truly takes no parameters (and returns nothing).
☬ੴ Bassi
^ not a good idea wnats email address probably for spam
☬ੴ Bassi
annoymously recieved? you use google and ask for email address makes no sense?
☬ੴ Bassi
Anonymous
First Calculator app ready to be deployed
Anonymous
☬ੴ Bassi
Amazing bro
Ammar
Cool
☬ੴ Bassi
What is antilog
Anonymous
the reverse of antilog
Anonymous
*The reverse of log Sorry
Dima
lol the whole qt lib for simple calc
Dima
but nice