problem in adding array elements

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JyotiR

    #1

    problem in adding array elements

    Hi.
    Pls help me i have the following code which is having error.This
    program is being written by Visual studio 2005
    Pls help me ASAP.
    #include "stdafx.h"

    void fun(int);
    int arr[10] = {1,2,3,4,5,6,7, 8,9,10};
    int _tmain(int argc, _TCHAR* argv[])
    {

    fun(arr[0]);
    return 0;
    }
    void fun(int *var)
    {
    int a = *(arr[0]+2);
    int b = *(arr[0]+3);
    int c;
    c = a+b;
    printf("\n %u",c);
    }
    Now the error is :
    illegal indirection

  • Jack.Thomson.v3@gmail.com

    #2
    Re: problem in adding array elements

    #include <stdio.h>

    void fun(int);
    int arr[10] = {1,2,3,4,5,6,7, 8,9,10};
    int main()
    {

    fun(arr[0]);
    return 0;
    }

    void fun(int var)
    {
    int a = *(arr+2);
    int b = *(arr+3);
    int c;
    c = a+b;
    printf("\n %u",c);
    }

    -------------------------------------------------------
    http://programmingsite.googlepages.com --- C Puzzles

    Comment

    Working...