Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Sichere ProgrammierungWhat breaks when your paid shell scripts run on macOS bash 3.2(01.10.2026 um 01:06 Uhr)
••
Sichere ProgrammierungAgents are starting to call each other. Nobody gave them receipts.(01.10.2026 um 01:10 Uhr)
•
Sichere ProgrammierungWhat I learned trying to index public Telegram communities(01.10.2026 um 01:17 Uhr)
•••••
Sichere ProgrammierungJoin Us Live: Hacktoberfest 2026 Launch with Exclusive Swag! 🎃🚀(01.10.2026 um 01:21 Uhr)
••
Sichere ProgrammierungWhat breaks when your paid shell scripts run on macOS bash 3.2(01.10.2026 um 01:06 Uhr)
••
Sichere ProgrammierungAgents are starting to call each other. Nobody gave them receipts.(01.10.2026 um 01:10 Uhr)
•
Sichere ProgrammierungWhat I learned trying to index public Telegram communities(01.10.2026 um 01:17 Uhr)
•••••
Sichere ProgrammierungJoin Us Live: Hacktoberfest 2026 Launch with Exclusive Swag! 🎃🚀(01.10.2026 um 01:21 Uhr)
••
Intelligence View
⚡ tsecurity.de Intelligence

Pointer Arithmetic: Traversing Memory without an Index

Why use an Index when you can touch the Memory? 👉 Day 2/30: Pointer Arithmetic. Most tutorials teach you to loop through arrays using i (the index). But in Sy…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

Why use an Index when you can touch the Memory? 👉



Day 2/30: Pointer Arithmetic.



Most tutorials teach you to loop through arrays using i (the index). But in Systems Programming, we often manipulate the address directly.



The Magic: When you write ptr++ in C, the compiler is smart. It doesn't just add "1" to the address. It adds sizeof(int) (usually 4 bytes).



If ptr was a char, it would add 1 byte. If ptr was a struct, it would jump the size of the whole struct.



This snippet allows us to iterate through data purely by comparing memory addresses, which is more direct and cleaner in low-level drivers.






The Code



Here is the C code for Day 2:








// Day 2: Traversing Memory without an Index

void iterate_with_pointers(const int *ptr, int size) {
// We don't need 'i' or 'array[i]'
// We just look at the end address
int *end = ptr + size;

while (ptr < end) {
// Dereference the current address to get value
printf("Value: %d\n", *ptr);

// Move the pointer to the next integer block
// (Jumps 4 bytes automatically)
ptr++;
}
}


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Pointer Arithmetic: Traversing Memory without an Index

Thematisch verwandte Begriffe: Pointer, Arithmetic, Traversing, Memory · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag