Re: First program in C - what is going on with function returns?



Thanks for the detailed response!

speakdate(int d, int m, int y)

What type is being returned? If you meant "nothing", specify void.

As per last reply, I want to return a string, but am not sure of the
syntax for returning arrays...

if (fmod(year,4)==0) {

At a guess, you simply want the modulus operand - % - here.

so... "if((year%4)==0)" ?

int main(void)

on a related note, is there a difference between "int main (void)" and
"int main ()" ?

speakdate(), as written, returns nothing, so treating it as if it does is
an error. That you get any output at all is simply a matter of accident.

should be able to fix this if i can return an array.

there's no way this could be the full code, as it cannot compile.

Hmmm, this was the full code I was using, compiling ok with bloodshed
dev-c++ on windows (a gcc based compiler). Can't see anything obvious
to raise the logging level, or to expert stricter code...

.



Relevant Pages

  • failed build for tk-8.4.5,1 and bittorrent
    ... error: syntax error before "ClientData" ... error: syntax error before "VOID" ... syntax er ror before "int" ... error: ...
    (freebsd-questions)
  • Re: Explain this
    ... At least in C and C++, the fact that we're assigning a char to x ... and C++ in a different way: in C, a character literal has type int, ... compiling it as C++ would assign to the global. ... but a language that was considerably different ...
    (comp.lang.cpp)
  • Re: problem with cast and unions
    ... my aim is to make a library compiling with suncc. ... The part where there is that problem is about conversion from a C float ... to a Small "cell" (actually an int). ... contain a valid representation of an 'int'. ...
    (comp.lang.c)
  • Defining an alias
    ... int __declspecSomeNewName ... The second declaration is the body of the function. ... All this syntax is quite horrible. ... The alias attribute causes the declaration to be emitted as an alias for another symbol, ...
    (comp.lang.c)
  • Re: Linking Problem
    ... the actual performance cost for CPU-bound code is ... With MF COBOL you have the option of compiling to INT, ...
    (comp.lang.cobol)