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



On Sun, 30 Apr 2006 12:02:11 UTC, ben.carbery@xxxxxxxxx wrote:

int main(void)

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

Yes. int main(void) declares a function returning nothing and having
no parameters. int main() declares a function returning nothing and
having an unspecified number of parameters of unspecified types.


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 is no need to return an array. Return a pointer to the string
you've builded already is all you needs. The string should not be an
auto variable becauser that will get indertimine with the return
statement. But using either a static array, a malloced memory area
(the calle would be required to free() it) or extern or at file scope.


--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!
.



Relevant Pages

  • Re: passing char arrays by reference
    ... I want to pass an array of strings to a function: ... int stuff{ ... stuff is an incompatible pointer type. ... string type; a "string" is a data format, ...
    (comp.lang.c)
  • Re: String of numbers into to array of numbers
    ... then read that string and have the string show the ... individual numbers as in an array. ... int arryCnt = 0; ... qStr= cStr.substring); ...
    (comp.lang.java.help)
  • (patch for Bash) regex case statement
    ... Following up on my previous patch for regex conditional tests, ... /* Return an array of strings; ... int dollarflag, zeropad, compareflag; ... SHELL_VAR *var; ...
    (comp.unix.shell)
  • Re: How to Return an array of strings in C (char**)
    ... int start=0; ... // to know the number of elements in the array ... The reason is that you fail to increment str. ... The you could have printed "here" before entering the main loop to see if you actually got there, then str + start to see where you go to in the string on each pass. ...
    (comp.lang.c)
  • Re: read keyboard input and storing in an array?
    ... When in a loop, how do I simply ... The data returned by 'br.readLine' would always be a String so I've stored ... simply convert it to an int as follows: ... you could copy 'myInt' to your array. ...
    (comp.lang.java.help)