CrazyEngineers
  • Passing Array To A Function Using Pointer In C

    Vishal Sharma

    Member

    Updated: Oct 21, 2024
    Views: 1.1K
    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)); 
    }
    
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Vishal Sharma

    MemberAug 2, 2012

    ooOooohhh!! crap!! my bad.. I forgot to place an "&" 😛 😛
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register