You are on page 1of 7

Capcim ns-22

Dal 3-09- 2

Nuwmyon Bhanoudor, Weds ard inu


nus Ma

Co

Aui
w

3 imlamant Pa op a fle
.a
ad ww.yo chonaules, uds, ard.1 Amuy
Jm am Gutpu

tgat , gals
Akolp 2 Ohun
de pu. td"n"mode
solp 3 he dala th
fub(Jundiom
top th Jrpu.takl
S Chau liues Od-o

t "Jrpuh.td MBde
Opn
Rabd daanat he

cet c(O wmlud EOF ond do the }olbedie


chons t I

-2 Chodk C
7.3-heuk o1

clo
Jnput Ixt
blex t
tx un w ms
Oun th da ukpu.
nds th ne chanadau chaas s. ity
0
md h. d) Gutput.put. bazt
ut put tal

tha ubpul-. tat a


Ap2 ep

Resual
slaimd and Veilúd
Oukpuk
#Includo <Stdfo.hn>
tincluolo 2 stdtb h>
vGu matn )

FILE fp,fpos
ca C
ink chanu lin, wGds ;
tp fopen C" Jnpu. bt o "
C=-NULL)
Foinf ( Could GPen tho 3
eit (o
3 be AlLsud
psintf n Enle the dala an t
press ctl4d t s e l
hil (Cc= qetchas CI)! =¬oF)

u cCcfe ),
3
fclose Cr
fp-fopen ( Inpus.tt","
choas =
wo6ds =linu =
O
wviie C(e- gete (fp))! =
EoF)
chass +t
i Cc'n')
Tines 44
liney 4+5 b ghretsuboAA

TCCE =|lc='ILc== In'lc= ="|0


wodds44

lese Cp),
p fopn (oulput.tat", w
s 2Ruopo Jvwe
pnt (fpo Tota characles
%dln'scchars) JY

peinf ( fpo, Tolad os d. 1. dl', wodr)


=

pintf CFpo ,
"
To taluh =d \n" dne
close Cfpo
d.Jus
J
owxb/up

, bes J
Jw
beo 03 )

3/00/y
-
dample Caupub
Ente theN data e e Stored on fhe file, press
ctsld o
sep
TEAMS POINTS
1. MUN S

15
.MAC
3 . CHE
14

p u t . bst
Tota chaxacters =5
Told wOTds.

Tod Tines

PolN
TEAMS
IS
MunN
S
2 MNC

3. cHE
#include <stdio.h>
#include <stdlib.h>
void main()

FILE fp, *fpo;


char C
int chars, words, lines ;

fp fopen ("Input .
txt", "w")
if (fp = NULL)
printf("Could not open the file");
exit(0
printf("\n Enter the data to be stored on the file, press ctrl+d to stop\n"
while((c =getchar 0) != EOF)
putc(C, fp);
fclose(fp);
fp fopen("Input.txt", "r");
chars-words= lines=0;
while((C getc (fp)) = EOF)
chars++
if (c == '\n')
lines+*
if (c I | c == '\t" || c == '\n' I| c == '\0')
Words++;

fclose(fp):
fpo fopen ("Output. txt", "w") ;
fprinti(fpo, "Total characters =
%d\n", chars);
fprintf(fpo, "Total words. = %d\n", Words);

fprintf(fpo, "Total lines =


%d\n", lines);
fclose(fpo);
o t a c h a r a c t e r s

Total lines

the tile, ctrld to atop


be atored on Prens
Ente th data ta
5

You might also like