Alberto Zavala
Alberto Zavala

Reputation: 13

Warning parameter names [When I try to load my array

So I'm getting this message when I try to load my array using pointers. I don't know why this keep appearing since the last program had no problem

#include<stdio.h>
#define T 10

void FLoad(int *);

void main () {
   int a[T];

   void FLoad(a);
}

void FLoad(int *a) {
   int x;

   for (x = 0; x < T; x++)
      scanf("%d", a+x);
}

And here is a little program that works perfectly

#include <stdio.h>

void FImp(int *, int );

main () {
   int a[] = {-10,-5,3,4}, tam;

   tam = sizeof(a) / sizeof(int);
   FImp(a, tam);
}

void FImp(int *a, int t) {
   int x;

   for (x = 0; x < t; x++)
      printf("%d ",*(a + x));
   putchar('\n');
}

Upvotes: 0

Views: 54

Answers (2)

Vengatesh Subramaniyan
Vengatesh Subramaniyan

Reputation: 953

void FLoad(a);

This won't call the function. The compiler will consider this as a function declaration. So call the function without void it will work fine.

Upvotes: 0

Stephen Docy
Stephen Docy

Reputation: 4788

You are using incorrect syntax when calling your function

void main()
{
    int a[T];
    void FLoad(a);
}

should be

void main()
{
    int a[T];
    FLoad(a);
}

or even better

int main(void)
{
    int a[T];
    FLoad(a);
}

You don't specify the function return value when you call it.

Upvotes: 1

Related Questions