carrayscharacteralphaalphabetic

How do I scan only alphabetic characters into an array in C?


I have a text file, and it is a paragraph with quotation marks, commas, periods, and spaces. I want my C program to scan only the letters into an array, while also making all of them lower case in the process. So if a text file said "Hello.", then the array would have: hello


Solution

  • There are multiple solutions. Two of the more "common" would be

    1. Read everything into memory, then copy only the wanted characters to the main array while converting to lower-case.

    2. Read character by character, saving only the characters you want to save while converting to lower-case.

    Both of these solutions are basically the same, they only differ in the actual file-reading part.