188k views
4 votes
The program below counts the number of characters in a file, assuming the file is encoded as ASCII. Modify the program so that it counts the number of characters in a file encoded as UTF-8. CODE: #include #include typedef unsigned char BYTE; int main(int argc, char *argv[]) { if (argc != 2) { printf("Usage: ./count INPUT\\"); return 1; } FILE *file = fopen(argv[1], "r"); if (!file) { printf("Could not open file.\\"); return 1; } int count = 0; while (true) { BYTE b; fread(&b, 1, 1, file); if (feof(file)) { break; } count++; } printf("Number of characters: %i\\", count); }

The program below counts the number of characters in a file, assuming the file is-example-1
User Edkeveked
by
4.1k points

1 Answer

5 votes

Answer:

Coding is a skill where you take instructions (the steps in a task) and translate it into a language the computer understands since computers do not communicate like humans. They communicate in a language called BINARY and it is uses 0's and 1's. Coders write the instructions using a programming language.

Step-by-step explanation:

Coding is a skill where you take instructions (the steps in a task) and translate it into a language the computer understands since computers do not communicate like humans. They communicate in a language called BINARY and it is uses 0's and 1's. Coders write the instructions using a programming language.

User David SN
by
3.7k points