How to open and close files in C++? fstream

Поделиться
HTML-код
  • Опубликовано: 26 авг 2024
  • You will learn how to close and open files and how to check if the file was opened properly. You also learn how to simply put text into a file.
    You can learn more about C++ fstream library in my course:
    www.udemy.com/...
    #fstream #cppshorts #cpp

Комментарии • 25

  • @GameDevForNoobs
    @GameDevForNoobs  6 месяцев назад

    Wanna try my course and find out more about C++? 🙂
    www.udemy.com/course/video-course-c-from-beginner-to-expert/?referralCode=F835B8AEE9C81FFE5BE5
    If you have any questions regarding C++ feel free to ask!

  • @confused_beekeeper
    @confused_beekeeper 5 лет назад +2

    I still can't get a file to open. Does it matter where you save it?

    • @olivialai.
      @olivialai. 5 лет назад +4

      @@viratsharma8036 I just figured it out too (thanks to the other comment about maybe the file being in the wrong file) So you need to first create a txt file IN the project file (not the debug file, and also not outside - just find the file that has your c++ source and create the txt file there) Hope this helped others too (I've been nearly driven mad by this lol)

    • @asfalt9217
      @asfalt9217 2 года назад

      @@olivialai. 2 Years later you saved me!! Thank you so much

    • @tsionmengistu4921
      @tsionmengistu4921 3 месяца назад

      @@olivialai. 4 years later you saved me!! i was losing my mind over this

    • @GameDevForNoobs
      @GameDevForNoobs  Месяц назад +1

      How cool is that we all have similar problems even tho so much time have passed :-)

    • @GameDevForNoobs
      @GameDevForNoobs  Месяц назад +1

      Looks like my video has the power to time travel! Glad I could finally save the day!

  • @niekemon9641
    @niekemon9641 4 года назад +3

    polak

  • @Frazer213
    @Frazer213 4 года назад +1

    How do i use C++ to actually open the text file into a new window?

    • @VideoKursPL
      @VideoKursPL 4 года назад

      What do you mean by a 'new window'?

    • @Frazer213
      @Frazer213 4 года назад +4

      @@VideoKursPLi want to use the c++ code to open the physical file. like in the note pad window.

    • @iseiaki
      @iseiaki 2 года назад

      @@Frazer213 have u done it? ://

    • @bigtone3166
      @bigtone3166 2 года назад

      @@Frazer213 how do you do it?

    • @shaheerahmad8437
      @shaheerahmad8437 2 года назад

      @@Frazer213 any updates????

  • @anapplefish
    @anapplefish 5 лет назад

    But how do we read files with the c++?

    • @VideoKursPL
      @VideoKursPL 5 лет назад

      This is free lecture, the rest is in the course :)

    • @djstapler
      @djstapler 2 года назад +4

      @@VideoKursPL all information should be free and publically available. Idc if it's in the course or not, if you know how to help you should. I don't so I can't

    • @GameDevForNoobs
      @GameDevForNoobs  2 месяца назад

      To read files in C++, you can use the ifstream class from the library.
      std::ifstream file("example.txt"); // Replace with your file path
      if (file.is_open()) {
      std::string line;
      while (getline(file, line)) {
      std::cout

  • @confused_beekeeper
    @confused_beekeeper 5 лет назад

    Psych I just figured it out.

  • @vodracseck
    @vodracseck Год назад

    poska