How to use isspace() function to check whether a character is a white-space in C

1 Answer

0 votes
#include <stdio.h>
#include <ctype.h>
 
int main(void)
{
    char s[] = "Unreal\tEngine 4 - DirectX 12\n";
	int i = 0;
	
	/* white-space list:
	   ' '	space (SPC)
       '\n'	newline (LF)
       '\r'	carriage return (CR)
       '\t'	horizontal tab (TAB)
       '\v'	vertical tab (VT)
       '\f'	feed (FF)
    */
	while (s[i])
	{
		if (isspace(s[i])) 
			printf("index - %d is isspace\n",  i);
		i++;
	}
    return 0;
}
 
  
/*
    
run:
    
index - 6 is isspace
index - 13 is isspace
index - 15 is isspace
index - 17 is isspace
index - 25 is isspace
index - 28 is isspace

*/

 



answered Jan 29, 2016 by avibootz
...