Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Use of diff pointers

Reply
Thread Tools

Use of diff pointers

 
 
Comp.Lang.c
Guest
Posts: n/a
 
      05-20-2006
Hello
Iam Niranjan... i have one small doubt.

void main()
{
int size;
size = sizeof(int *);
printf("\n size of int *------>%x"size);
size = sizeof(char *);
printf("\n size of char *------>%x"size);
size = sizeof(float *);
printf("\n size of float *------>%x"size);
}
here i got the same size for all three.
when all three taking the same size... why we need different type of
pointers..
plz clarify any one..
Thanking you
Niranjan

 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      05-20-2006
Comp.Lang.c said:

> Hello
> Iam Niranjan... i have one small doubt.
>
> void main()


Lesson 1: main returns int, not void.

When you have absorbed that lesson, let us know.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
 
Reply With Quote
 
 
 
 
Comp.Lang.c
Guest
Posts: n/a
 
      05-20-2006
whats the relation between main return type & pointers size...?

 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      05-20-2006
Comp.Lang.c said:

> whats the relation between main return type & pointers size...?


None whatsoever, because main always returns int.

When you understand that, we can move on to the next error in your example
program. There doesn't seem to be any point in teaching you new things
until you've understood the old things correctly. It would be like building
a house on sand.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      05-20-2006
"Comp.Lang.c" <> writes:
> Iam Niranjan... i have one small doubt.


I suggest you pick a name for yourself other than "Comp.Lang.c".
That's the name of the newsgroup; referring to yourself by the same
name is bound to cause confusion. (Using your own real name is
usually best, but some people choose to use pseudonyms.)

> void main()


int main(void)

> {
> int size;
> size = sizeof(int *);
> printf("\n size of int *------>%x"size);
> size = sizeof(char *);
> printf("\n size of char *------>%x"size);
> size = sizeof(float *);
> printf("\n size of float *------>%x"size);
> }
> here i got the same size for all three.
> when all three taking the same size... why we need different type of
> pointers..


Because they point to different types.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Typhonike
Guest
Posts: n/a
 
      05-20-2006
they have fixed in size because pointer do not hold the variable's
itself they only hold the adresses.But it do not mean that one type of
pointer can hold all the types.we have to tell the compiler "this
pointer is use for this type of variable".the reason is c uses STRONGLY
TYPE CHECKING.we can't change variables types(of course pointers are
variavles too) during the run time and compile time.

 
Reply With Quote
 
Comp.Lang.c
Guest
Posts: n/a
 
      05-20-2006
Thanq Mr Keith Thompson.
its very very nice meeting you.
Thanking you, for your great Help.
Niranjan Podduturi.
+919849238297

 
Reply With Quote
 
Comp.Lang.c
Guest
Posts: n/a
 
      05-20-2006
Hello Sir,
I know ...
void main returns int.
Iam niranjan podduturi.
Iam from Hyderabad/India
Thanking you Sir.
Niranjan Podduturi

 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      05-20-2006
Comp.Lang.c said:

> Hello Sir,
> I know ...
> void main returns int.


No, main returns int.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
 
Reply With Quote
 
pete
Guest
Posts: n/a
 
      05-20-2006
Typhonike wrote:
>
> they have fixed in size because pointer do not hold the variable's
> itself they only hold the adresses.


No.

sizeof(int *), sizeof(char *), and sizeof(float *)
are all equal on OP's implementation through sheer coincidence.

The relative sizes of those types of pointers
is unspecified by the rules of the C programming language.

--
pete
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointers, pointers, pointers... cerr C Programming 12 04-07-2011 11:17 PM
Diff CSS styles for diff INPUT TYPE='s? A Traveler ASP .Net 6 08-31-2004 09:17 PM
[ANN] Diff::LCS 1.1.0, Diff::LCS 1.0.4 Austin Ziegler Ruby 3 08-09-2004 06:34 AM
diff Process under diff users Cyril Vi?ville Perl 1 06-29-2004 06:22 PM
Same sessionID retuned to diff browsers in diff machines Berrucho ASP .Net 2 12-05-2003 02:23 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57