difference between tab ,space and blank in C -


i came across following code in ritchie , kernighan c,for counting no. of words ..

#include<stdio.h> #define in 1 #define out 0 main() {     int c,n1,nw,nc,state;     state = out;     n1 =nw = nc = 0;     while((c = getchar())!=eof)     {         ++nc;         if(c == '\n')             ++n1;         if(c == ' '||c == '\n' ||c == '\t')             state = out;         else if(state == out)         {             state = in;             ++nw;         }     }      printf("%d %d %d\n",n1,nw,nc); } 

i guess here c == ' ' , c == '\t' doing same job.

can explain me difference between tab, space, whitespace, blank, form feed , vertical tab?

spaces , tabs have different representations in ascii. <space> 0x20, while <tab> 0x09. when program checks current character, both possibilities need tested.

also worth noting newline character using '\n', "line feed", conventional newline character unix/linux/bsd. on windows, typical newline represented "\r\n" or crlf ("carriage return" , "line feed").

i don't know characters "vertical tab" used much. many of "control characters" go days when used give printers instructions on how move head.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -