Logo

Programming-Idioms

History of Idiom 110 > diff from v57 to v58

Edit summary for version 58 by Arnie97:
New C implementation by user [Arnie97]

Version 57

2020-12-09, 14:42:56

Version 58

2020-12-11, 07:28:56

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Imports
#include <ctype.h>
#include <stdbool.h>
Code
bool blank = true;
for (const char *p = s; *p; p++) {
	if (!isspace(*p)) {
		blank = false;
		break;
	}
}
Comments bubble
type of s is char *