Computers & Internet Logo

Related Topics:

Posted on Aug 31, 2008

C PROGRAM I NEED ALGORITHM OF A C PROGRAM WHICH COUNT LINE OF CODE OF A FILE

1 Answer

Anonymous

Level 1:

An expert who has achieved level 1.

Problem Solver:

An expert who has answered 5 questions.

  • Contributor 5 Answers
  • Posted on Sep 29, 2008
Anonymous
Contributor
Level 1:

An expert who has achieved level 1.

Problem Solver:

An expert who has answered 5 questions.

Joined: Sep 29, 2008
Answers
5
Questions
0
Helped
10120
Points
6

#include <stdio.h>
int main ()
{
FILE * pFile;
int c;
int n = 0;
pFile=fopen ("test.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
{
do { //DO
c = fgetc (pFile);
if (c == '$') n++;
} //DO
while (c != EOF);
fclose (pFile);
printf ("File contains %d$.\n",n);
}
return 0;
}

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

120 views

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

ADMIN Andrew
ADMIN Andrew

Level 3 Expert

73810 Answers

ADMIN Eric
ADMIN Eric

Level 3 Expert

42247 Answers

Brad Brown

Level 3 Expert

19190 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...