include stdio include stdlib include string include locale int main in

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
int main()
{
int size, i, n;
FILE *text;
setlocale(LC_ALL,"");
if ((text=fopen("main1.c","rb"))==NULL)
{
perror("");
return EXIT_FAILURE;
}
else
{
fseek(text, 0L, SEEK_END);
size = ftell(text);
fseek(text, 0L, SEEK_SET);
char *buffer = (char *)malloc(size+1);
fread((void *)buffer, 1, size, text);
for (i=0;i<size;i++)
{
switch(buffer[i])
{
case '+':{printf("%s","SUMA"); continue;}
case '-':{printf("%s","MULT"); continue;}
case '/':{printf("%s","DIV"); continue;}
default:{printf("%c",buffer[i]); continue;};
}
}
while(*buffer)
{
if(*buffer=='=')
{
n++;
}
buffer++;
}
}
printf("\vКількість знаків =(всього): %i\n", n);//а в тебе треба окремо для кожного рядку
return 0;
}