strange C syntax

Mar 22, 2010 at 1:07pm
I have come across a C syntax in which there is no return value for the functions and the arrays seem to be initialized strangely as well. Not how I've been taught to write C programs but it compiles fine, what is the reason for that?

A code example would be:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

char array[] = "abcdef"
               "ghijkl"
               "mnopqr";

func()
{
    //  insert some code here
}

main()
{
    // insert some code here e.g. func();
}
Last edited on Mar 22, 2010 at 1:08pm
Mar 22, 2010 at 1:53pm
I believe some compilers will automatically make a function return 'int' if nothing is declared.
Mar 22, 2010 at 2:13pm
Assignment of char arrays from string literals is supported by both C and C++.
Omitting the return type of a function is standard C and is not permissible in C++. (In C, if left
unspecified, the return type defaults to int).


Mar 22, 2010 at 2:45pm
The unspecified arguments mean pass anything in C, but means void, no arguments, in C++.
Mar 31, 2010 at 5:24pm
> The unspecified arguments mean pass anything in C, but means void, no arguments, in C++.

I guess that is just backwards compatibility? I don't see a way of accesing the passed argument.

(Well I could get it, non-portably, and it's more effort than it's worth...)
Topic archived. No new replies allowed.