Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

increasing pointers

Featured Replies

Posted

hi all,

this little problem is killing me:

char data[256];
mystruct* mystructptr;
//copy some stuff into the data buffer

int the buffer "data",there are 12 junk bytes, but then there is a mystruct struct.

i need to point to that struct...

way #1:

mystructptr = (mystruct*)(data+12);

this works just fine, mystructptr points to the address of "data" + 12.

this, however, doesnt work:


mystructptr = (mystructptr*)data;
mystructptr = (mystruct*)(mystructptr + 12);
or
mystructptr = (mystructptr + 12)
or
mystructptr += 12;

the data buffer gets increased by ~0x400 bytes, not 12...

i really cant see why #2 wouldnt work. :(

Edited by deepzero

It's a standard C feature (quote from Kernighan's Programming in C tutorial):

If p is a pointer to a structure, any arithmetic on p takes into account the actual size of the structure. For instance, p++ increments p by the correct amount to get the next element of the array of structures.

There are several ways to do what you want to, something like this:


mystructptr = ((byte *)mystructptr + 12);
  • Author

most awesome,kao!

my book didnt (doesnt) mention it... :/

edit:

could`ve figured it out myself, though, huh? :)

Edited by deepzero

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.