Logo

Programming-Idioms

History of Idiom 96 > diff from v31 to v32

Edit summary for version 32 by Dodopod:
New C implementation by user [Dodopod]

Version 31

2017-04-29, 07:18:29

Version 32

2017-05-27, 19:49:42

Idiom #96 Check string prefix

Set boolean b to true if string s starts with prefix prefix, false otherwise.

Illustration

Idiom #96 Check string prefix

Set boolean b to true if string s starts with prefix prefix, false otherwise.

Illustration
Imports
#include <stdbool.h>
#include <string.h>
Code
bool b = !strncmp(s, prefix, sizeof(prefix)-1);