How to read a file and get words in C++

前端 未结 4 988
温柔的废话
温柔的废话 2021-01-16 02:06

I am curious as to how I would go about reading the input from a text file with no set structure (Such as notes or a small report) word by word. The text for example might b

4条回答
  •  囚心锁ツ
    2021-01-16 02:45

    You can use the scanner technique to grabb words, numbers dates etc... very simple and flexible. The scanner normally returns token (word, number, real, keywords etc..) to a Parser.

    If you later intend to interpret the words, I would recommend this approach.

    I can warmly recommend the book "Writing Compilers and Interpreters" by Ronald Mak (Wiley Computer Publishing)

提交回复
热议问题