Passing Array To A Function Using Pointer In C

Vishal Sharma

Vishal Sharma

@vishal-pysGmK Oct 21, 2024
hey guys!
i have a small trouble, hope it'll be solved soon here..
facing problem in passing array to a function using pointer.
while compiling in borland c it says "Processor fault"
and in DEV C it compiles but doesn't give any output
here's the code
#include<stdio.h>
#include<conio.h>
void passarray(int *,int);
int main()
{
const int size=10; 
int a[size];
printf("Enter the elements= ");
for(int i=0;i<size;i++)
  scanf("%d",a[i]);
passarray(a,size);
getch();
return 0;
}
 
void passarray(int *x,int y)
{         
     
    for(int i=0;i<y;i++)
    printf("%d",*(x+i)); 
}

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Vishal Sharma

    Vishal Sharma

    @vishal-pysGmK Aug 2, 2012

    ooOooohhh!! crap!! my bad.. I forgot to place an "&" 😛 😛