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
- debian bookworm: publib-dev 0.40-3+b1 Β· BSD-2-Clause
- debian trixie: publib-dev 0.40-4 Β· BSD-2-Clause
- ubuntu jammy: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu noble: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu questing: publib-dev 0.40-4
- ubuntu resolute: publib-dev 0.40-4build1 Β· BSD-2-Clause
- ubuntu stonking: publib-dev 0.40-4build1 Β· BSD-2-Clause
- Copyright (c) 1994-2006 Lars Wirzenius. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms