MEMREV(3pub)

πŸ’– MEMREV(3pub) β€” bestie's guide to flipping arrays πŸ’–

okay so this is a page from the C Programmer's Manual, and it's literally all about one tiny iconic function: memrev. she's from publib btw, iykyk 🫢


✨ NAME ✨

memrev β€” reverse an array in place. no copy, no extra memory, just vibes and swapping πŸ¦‹


🌸 SYNOPSIS 🌸

#include <publib.h>
void *memrev(void *block, size_t elsize, size_t elnum);

πŸŽ€ DESCRIPTION πŸŽ€

memrev will reverse an array, by swapping the contents of its elements. that's it. that's the whole function. no cap, she does one thing and she eats πŸ”₯

like the way that it just takes your array and flips the whole order around, no notes πŸ’…


πŸ‘‘ RETURN VALUE πŸ‘‘

memrev returns its first argument. so like, it hands you back block, your own pointer, as a little treat πŸ“


⭐ EXAMPLE ⭐

to reverse an integer array one might do the following, bestie:

int array[4] = { 1, 2, 3, 4 };

memrev(array, sizeof(array[0]), 4);

This will result in the array being { 4, 3, 2, 1 }.

periodt. πŸ’œ


🌈 SEE ALSO 🌈

(the little publib family fr fr)


πŸ’– AUTHOR πŸ’–

Lars Wirzenius (lars.wirzenius@helsinki.fi)


ngl this is the entire page, there's no hidden lore, no deprecated warnings, no undefined behaviour lurking. just a cute little array-flipper. go forth and reverse, main character 🌟

okay bye ily, this was the Publib version of the C Programmer's Manual β€” MEMREV(3pub) β€” mwah πŸ’…πŸ§šβœ¨

πŸ“¦ where this page comes from