-3

I'm trying to write a program to facilitate processing of a document at work. Ordinarily, this file is opened in notepad and scanned manually; the program would scan it instead, and output elsewhere.

The problem is, the input file has a .prt file type, despite functionally being a txt (and not a CAD file).

How can I get C++ to treat the file as if it were a .txt (or change the file type and overwrite the original input), ideally with fstream?

  • 3
    You don't need to do anything special, it will be treated as text through the [fstream](https://en.cppreference.com/w/cpp/io/basic_fstream) facility. – Eljay May 26 '22 at 13:05
  • 1
    As any [decent book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list/388282#388282) should have taught you, a file stream is opened either in text-mode, or in binary-mode. Text-mode is default. The file suffix doesn't matter, it's just part of the file-name and isn't parsed in any way. – Some programmer dude May 26 '22 at 13:05
  • 2
    Give it a try! I think you'll find nothing is stopping you from succeeding except your doubt that you might not succeed. – Wyck May 26 '22 at 13:15
  • Thank you for your assistance. Sorry for the rookie question, I just couldn't find anything about it online (and have no books on or formal education in C++). – MisterStreamline May 26 '22 at 13:23

0 Answers0