Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

QUICK QUESTION, ACT NOW

Name: OMGS HELP NOW!!! 2008-05-21 16:17

If I typecast a pointer to a different kind of pointer, and incrementz the pointer, will the pointer be incremented by the amount accordiing to the typecast or the real pointer?

Example:

[b]long[/b]* ptr;

([b]char[/b]*) ++ptr;


Which is the result?
A) ptr is increased by sizeof(long)  (ie. 4)
B) ptr is increased by sizeof(char)  (ie. 1)

thx in advance, kindly /prog/ warriors

Name: bbcode failure 2008-05-21 16:18

ah stupid bold tags

long* ptr;

(char*) ++ptr;

Name: Anonymous 2008-05-21 16:21

Since the cast to char* is applied to the result of ++ptr, then the increment is performed before the cast, and ptr is increased by sizeof(long).

If you did:
char* q = (char*)ptr;
q++;


q would increase by sizeof(char).

Name: Anonymous 2008-05-21 16:24

DON'T HEL-




>>3
fuck.

Name: Anonymous 2008-05-21 16:27

>>3
ok..  but I just want to increase the long ptr by a char's size, rather than the expected 4 bytes

(ps. lol @ actually getting help on /prog/ )

Name: Anonymous 2008-05-21 16:30

DON'T HELP HIM.

Name: Anonymous 2008-05-21 16:31

>>5
Forget it, it's NP-complete.

Name: Anonymous 2008-05-21 17:41

WHAT IS A CHAR* AND HOW IS IT DIFFERENT FROM CHAR

Name: Anonymous 2008-05-21 17:45

>>1
long* ptr;
Bad.
(char*) ++ptr;
Good.
(++ ptr (* char))
Better.

Name: Anonymous 2008-05-21 18:01

>>9
What?

Just tell me how to increase the pointer by only 1 byte instead of 4

Name: Anonymous 2008-05-21 18:15

>>10
You can't be serious.

Name: Anonymous 2008-05-21 18:29

>>10
Why? So that you can generate CPU exceptions via unaligned data access?

Name: Anonymous 2008-05-21 19:00

>>12
Yes.  OK NOW TELL ME GO

Name: Anonymous 2008-05-21 20:06

>>13
Unless you are severely retarded, what you're asking is simple enough that you can figure out by yourself.

Name: Anonymous 2008-05-21 23:39

++(char *)ptr

Name: Anonymous 2008-05-21 23:51

Oh well, at least now that >>15 gave him the answer1 he might go away.

Name: Anonymous 2008-05-22 4:00

>>15
[Warning] use of cast expressions as lvalues is deprecated.

Name: Anonymous 2008-05-22 4:34

>>17
Nonsense.

Name: Anonymous 2008-05-22 4:40

>>18
That's what it told me :[

But it did work so thx to whomever posted it...  I just want to be able to do it without the annoying [Warning].

Name: Anonymous 2008-05-22 4:49

>>19
fuck off

Name: Anonymous 2008-05-22 5:55

a pointer points

Name: Anonymous 2008-05-22 6:32

>>17,19
ptr = (long *)((char *)ptr + 1);
but you should not do this.

Name: Anonymous 2008-05-22 6:40

>>22
Why not?

Name: Anonymous 2008-05-22 6:42

>>17
-w

Name: Anonymous 2008-05-22 6:53

>>23
instead of this:
ptr = (long *)((char *)ptr + 1);
long val = *ptr;


you should do this:
long val = ptr[0] << CHAR_BIT | ptr[1] >> (sizeof(long) - 1) * CHAR_BIT;

Name: Anonymous 2008-05-22 6:53

>>23
Alignment issues you damn retard.
>>25
No, he shouldn't.

Name: immense failure 2008-05-22 7:02

Oh right.  Well tHANKS FOR HELPING ME GUISE, I AM NOW ON MY WAY TO BECOMING AN EXPERT PROGRAMMER

Name: Anonymous 2008-05-22 7:05

Why don't you just fucking do it and printf the result?

Name: Anonymous 2008-05-22 7:09

>>27
I don't believe we helped you to guise at all. What are you talking about?

Name: Anonymous 2008-05-22 8:47

>>26
No, he shouldn't.
why not? endianness issues are much better than alignment issues!

Name: Anonymous 2008-05-22 8:51

>>26,30
He should use Haskell. It all depends on situation.

Name: Anonymous 2008-05-22 9:28

C is the only language anybody really needs these days.

Name: Anonymous 2008-05-22 9:40

>>32
Sure, if you're a millionare.

Name: Anonymous 2008-05-22 11:48

>>30
Big endian, middle endian and the DeathStation 9000 can go fuck themselves. They´re like starting an array at 1, ½ and π respectivily.

Name: Anonymous 2008-05-22 12:23

lol @ middle-endian

Name: Anonymous 2008-05-22 13:59

wuts an edian?

Name: Anonymous 2008-05-22 14:10

>>36
It's a term describing what side of the egg you eat first: the big end or the little end.

Name: Anonymous 2008-05-22 14:36

>>37
Clever. Now I can finally remember big, middle and small endian.

Name: Anonymous 2008-05-22 15:05

>>38
Bonus points if you know where it comes from, though. No wikipediaing!

Name: Anonymous 2008-05-22 15:19

>>37
u not telling truth i no its sumthing with computa

Name: Anonymous 2008-05-22 15:21

>>40
The term was around long before the invention of computers, you ignorant fuck.

Name: HAX MY ANUS MEME FAN 2008-05-22 16:31

in b4 Gulliver
Believe it or not gentlemen, it is entirely possible to be a well-read man and still appreciate the fine humor of the  ``HAX MY ANUS" meme.

Name: Anonymous 2008-05-22 16:36

>>41
i m confoused so it s reely wut u said?

Name: Anonymous 2008-05-22 16:53

>>42
Gulliver from Gulliver's travels? I'm familiar with this story.

Name: Anonymous 2008-05-22 17:21

>>42,44
same person

Name: Anonymous 2008-05-22 18:08

>>45
same nigglet

Name: Anonymous 2008-05-22 18:55

>>46
son of a black person

Name: Anonymous 2008-05-22 19:02

typecast my anus

Name: Anonymous 2009-03-06 11:13


re-enabled it after being   read in once   instead of reading   in a big   plus All it   a day return.

Name: Anonymous 2010-11-26 19:08

Name: Sgt.Kabukiman覧ዕ 2012-05-23 5:56

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List