Home » questions » How to count letters,lines,digits ,blank spaces and others in the program in c programming?

How to count letters,lines,digits ,blank spaces and others in the program in c programming?

2006-08-07 04:34:38, Category: Programming & Design

Answers

  1. vaderchild

    On 2006-08-07 04:49:18


    Copy the whole this into Word and press F7. Ignore all spelling & grammatical errors. A summary should appear. If not configure it in the Tools Menu >> Options Then repeat the steps. It's pretty self-explanatory... You'e a programmer after all.
  2. warjolt

    On 2006-08-07 04:55:42


    void count (char *text, int *letters, int *lines, int *spaces){ *letters = 0; /* all files start on line 1 */ *lines = 1; *spaces = 0; /* keeps incrementing pointer until it finds \0*/ for(;*text; text++){ if (isalpha(*text)) *letters++; else if(*text == '\n') *lines++; else if(*text == ' ' || *text == '\t') *spaces++; } }