ustrstr(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– ustrstr β€” bestie edition πŸ’–

okay so this one's from the Allegro manual, it's a C function, and it's literally the "where's my substring at" machine. πŸ¦‹


🌸 NAME 🌸

ustrstr β€” finds the first occurrence of a string in another one. (Allegro game programming library, if you didn't already clock that. πŸ‘‘)


✨ SYNOPSIS ✨

#include <allegro.h>

char *ustrstr(const char *s1, const char *s2);

like, that's the whole vibe. two strings in, one pointer out. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

okay so bestie, here's the tea: ustrstr finds the first occurrence of the string s2 inside the string s1. that's it. that's the function. no cap. πŸ”₯

example, because we love a demo:

char *p = ustrstr("hello world", "world");

so it's out here hunting through s1 looking for the earliest spot where s2 starts matching. not the last spot, the first one. main character behavior only. ⭐


🌈 RETURN VALUE 🌈

  • returns a pointer within s1 pointing at where the match starts 🫢
  • or NULL if s2 wasn't found 😭
so like, always check for NULL before you go dereferencing, okay? i'm not gonna watch you crash. πŸ™ˆ

πŸ’œ SEE ALSO πŸ’œ


mwah πŸ’‹ that's a wrap β€” this lil page came to you from Allegro, version 4.4.3, and it's the ustrstr(3) entry of the Allegro manual. go find your substrings, bestie, you got this. πŸŽ€βœ¨

πŸ“¦ where this page comes from