GATE CSE
First time here? Checkout the FAQ!
x
0 votes
94 views
#include<Stdio.h>
main()
{
    int *a[10];
    *a[0]=323;
  printf("%d",*a);

}

// i m getting error what is error here ?
asked in Programming by Active (2k points)   | 94 views

yes i think u r right 
it is right if elements r contiguous
suppose each element of array of pointers pointing to each element of an array then it may right bt nt ever as in ur case 
srry if any problem occur due 2 me...
https://www.tutorialspoint.com/cprogramming/c_array_of_pointers.htm

my question is modification of that question :)

valid code is this

int main(void) {
	int *a[10];
    a[0]=323;
    printf("%d",a[0]);
	return 0;
}

 

srestha  tell , below description is right ?

can u write full formula with means

e.g. int *a[10];

a element  1000 1200 1300 1400 1500 1600 1700 1800

a index       0        1       2    3       4       5      6       7

memory    100     102    104  106  108  110    112   114

location

no how to calculate a[2][1] ?

according to u it will  *(*(a+2)+1) =

first i will solve inner part a+2 which wil 100+2 * size of type (here int , so 2 )

a+2 leads to 100+4 = 104

*104 leads 1300

so *(1300 + 1) which leads 1300 + 2 = 1302

vaue at 1302 which leads here error //bcz there is no element at memory location

is thiz whole scenario is right ?

Please log in or register to answer this question.

Related questions

0 votes
1 answer
2
asked in Algorithms by Wanted Active (2k points)   | 52 views
0 votes
1 answer
3
asked in Programming by Mandeep Singh Active (1.3k points)   | 85 views


Top Users Jun 2017
  1. Bikram

    3810 Points

  2. Arnab Bhadra

    1526 Points

  3. Hemant Parihar

    1502 Points

  4. Niraj Singh 2

    1491 Points

  5. Debashish Deka

    1434 Points

  6. junaid ahmad

    1432 Points

  7. pawan kumarln

    1278 Points

  8. Rupendra Choudhary

    1242 Points

  9. rahul sharma 5

    1236 Points

  10. Arjun

    1218 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 Jun 26 - Jul 02
  1. pawan kumarln

    410 Points

  2. Arjun

    258 Points

  3. akankshadewangan24

    254 Points

  4. Abhisek Das

    220 Points

  5. Debashish Deka

    188 Points


23,421 questions
30,139 answers
67,562 comments
28,469 users