Logo

Programming-Idioms

History of Idiom 110 > diff from v58 to v59

Edit summary for version 59 by programming-idioms.org:
[C] +DocURL isspace

Version 58

2020-12-11, 07:28:56

Version 59

2020-12-28, 22:41:21

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>
Imports
#include <ctype.h>
#include <stdbool.h>
Code
bool blank = true;
for (const char *p = s; *p; p++) {
	if (!isspace(*p)) {
		blank = false;
		break;
	}
}
Code
bool blank = true;
for (const char *p = s; *p; p++) {
	if (!isspace(*p)) {
		blank = false;
		break;
	}
}
Comments bubble
type of s is char *
Comments bubble
s has type char*
Doc URL
http://www.cplusplus.com/reference/cctype/isspace/