October 14, 2005
Hi, I'm new to C and am learning it for my software engineering course. I'm trying to compile a basic array program;

#include <stdio.h>
main()
{
int a[10];
for(int i=0;i<10;i++)
{
a[i]=i;
}
printarr(a);
}

void printarr(int a[])
{
for(int i=0;i<10;i++)
{
printf("value in array %d\n",a[i]);
}
}

When I compile I get the output;

C:\dm\bin>dmc third.c
{
^
third.c(13) : Error: 'printarr' previously declared as something else
It was declared as: int C func(int *)
It is now declared: void C func(int *)
--- errorlevel 1

It works when I change void to int, however I thought that without a return value void was used. The code is taken from C & Data Structures by P.S Deshpande and O.G Kakde.

Thanks.


October 14, 2005
greppinFunk wrote:
> Hi, I'm new to C and am learning it for my software engineering course. I'm
> trying to compile a basic array program;
> 
> #include <stdio.h>

void printarr(int a[]);		// PROTOTYPE

> main()
> {
> int a[10];
> for(int i=0;i<10;i++)
> {
> a[i]=i;
> }
> printarr(a);
> }
> 
> void printarr(int a[])
> {
> for(int i=0;i<10;i++)
> {
> printf("value in array %d\n",a[i]);
> }
> }
> 
> When I compile I get the output;
> 
> C:\dm\bin>dmc third.c
> {
> ^
> third.c(13) : Error: 'printarr' previously declared as something else
> It was declared as: int C func(int *)
> It is now declared: void C func(int *)
> --- errorlevel 1
> 
> It works when I change void to int, however I thought that without a return
> value void was used. The code is taken from C & Data Structures by P.S Deshpande
> and O.G Kakde.
> 
> Thanks.
> 
> 


-- 
ManiaC++
Jan Knepper

But as for me and my household, we shall use Mozilla...
www.mozilla.org