return types default to int 
Author Message
 return types default to int

Trying to compile the following code:
-------------------------------------
/* Passing an array of pointers to a function. */

#include <stdio.h>

void print_strings(char *p[], int n);

main()
{
    char *message[8] = { "Four", "score", "and", "seven",
                     "years", "ago,", "our", "forefathers" };

    print_strings(message, 8);
    return(0);

Quote:
}

void print_strings(char *p[], int n)
{
    int count;

    for (count = 0; count < n; count++)
        printf("%s ", p[count]);

Quote:
}

----------------------------
the following warning appears:
myprogram.c:8 : warning: return type defaults to 'int'
Can you tell me where is the error?
Amir.


Mon, 04 Apr 2005 04:26:05 GMT  
 return types default to int

Quote:

> main()
> {
> the following warning appears:
> myprogram.c:8 : warning: return type defaults to 'int'
> Can you tell me where is the error?

You didn't explicitly specify a return type for main(), like
this:
        int main()
        {
--
"In My Egotistical Opinion, most people's C programs should be indented six
 feet downward and covered with dirt." -- Blair P. Houghton


Mon, 04 Apr 2005 04:25:40 GMT  
 return types default to int

Quote:
>    char *message[8] = { "Four", "score", "and", "seven",
>                     "years", "ago,", "our", "forefathers" };

It should be "fathers", by the way. ;)

--
Eric Amick
Columbia, MD



Wed, 06 Apr 2005 09:00:55 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. HISTORY: Why return int default?

2. Help solve argument about default return type

3. Convert C++ (return type int, long, user-define, etc) function into COM/ATL

4. How to change int type to char type

5. how to tranform double type to int type

6. Help with: C2392 - covariant returns types are not supported in managed types

7. undefined type in arg list vs. return type

8. HRESULT return type turns into void when adding class from type library

9. int func(int) versus int func(int *) efficacy.

10. functions defaulting to int

11. Default to 'int'

12. stdin function that returns default when no key pressed

 

 
Powered by phpBB® Forum Software