C Reference Control Character Test: iscntrl()

The iscntrl() function returns a non-zero if its argument is a control character. If there is no control character encountered, then zero is returned.

iscntrl() source code example:


#include<stdio.h>
#include<ctype.h>

int main()
{
	int counter=0;

	char str[]="line one \n line two \n line three \n";
	while (!iscntrl(str[counter]))
	{
		putchar (str[counter]);
		counter++;
	}

	return 0;
}

Note: Only line one is printed because after line one there is a control character ‘\n’ (ASCII code 0x0a)

This entry was posted in C Reference ctype.h Functions. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed. Tweet This! Tweet This! or use to share this post with others.

Comments are closed.