You are not logged in. Please login at www.codechef.com to post your questions!

×

assignment operation on Pointers

Am a absolute beginner in C programming. My doubt is int a=10; int *b;

what is the difference between

b=a; and b=&a; ?

asked 20 Oct '12, 23:55

prathaprajiv's gravatar image

0★prathaprajiv
6112
accept rate: 0%


b=a ... will result in b pointing to the memory location of 10 ( which is the value of a ), value of b will have some undefined value.
b=&a .... will result in b pointing to the location of a . hence
b will have the value 10 .

link

answered 21 Oct '12, 12:08

mayagr's gravatar image

1★mayagr
42113
accept rate: 100%

b=a is a assignment statement which assigns the value of a to b. In the other case b=&a is a pointer notation a=10 is stored in a particular location and the address of the location is assigned to b.In other words b points the location of a.

link

answered 21 Oct '12, 00:55

arun92's gravatar image

0★arun92
0111
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,477
×62

question asked: 20 Oct '12, 23:55

question was seen: 1,006 times

last updated: 21 Oct '12, 12:08