C Reference Printing Character: isprint()

The function isprint() returns a non-zero if its argument is a printable character (including a white-space). If the argument is not a printable character (like the newline character ‘\n’ ) , then zero is returned.

isprint() 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 (isprint(str[counter]))
	{
		putchar (str[counter]);
		counter++;
	}
	return 0;
}

Note: will only print line one, because the newline character is not printable.

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.