Close
Close

Cannot Scan Array With Pointer From User (Scanf)

   bagadurshah

This Declaration of (*p)[n] for Pointer Array (Array with Pointer).

I cannot Scanf Array From User

This Program

#include <stdio.h>

int main()
{
    int i,n;
    scanf("%d",&n);
    int (*a)[n];
    int *p;
    p = *a;
    for(i=0;i<n;i++)
    {
        scanf("%d",(p+i)); <em><strong>// This Shows Segmentation Fault </strong></em>
    }
    for(i=0;i<n;i++)
    {
        printf("%d",*(p+i));
    }

    return 0;
} 

.

PLEASE REPLY WITH A CORRECT ANSWER .


Answers

Ask Yours
Post Yours
Write your answer