| dodaj.c | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <stdio.h>
#include <stdlib.h>
void main() {
FILE *datoteka;
if ((datoteka=fopen("c:\\podatki.txt", "r"))==NULL) {
printf("Datoteka podatki.txt ne obstaja!\n");
exit(1);
}
int i=0; char c;
while ((c=getc(datoteka))!=EOF)
if (c=='\n') i++;
fclose(datoteka);
datoteka=fopen("c:\\podatki.txt", "a");
fprintf(datoteka, "%d\n", i);
fclose(datoteka);
}
|