Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

weird behaviour of scanf

$
0
0
#include<stdio.h>
#include<conio.h>
void array(int * ,int );


int main()
{
    int n,a[20];
    printf("Enter the size of the array");
    scanf("%d",&n);
    array(&a[0],n);
}
void array(int *j,int n)
{
    int i;
    for(i=0;i<n;i++)
    {
        printf("\n Enter the elements of array");
            scanf("%d",j);
                        j++;
    }
    printf("The elements of array are");
    for(i=0;i<n;i++)
    {
        printf("\n%d",*(j));
                j++;



    }
}

IN #scanf# IF IN PLACE OF THAT I AM DOING THIS THEN THE CODE IS SUCCESSFULLY EXECUTING. CAN ANYONE EXPLAINN ME WHY?? though both means same..

scanf("%d",(j+i)); and deleting j++;


Viewing all articles
Browse latest Browse all 39796

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>