C++ Programming Tutorial 60 - Writing to Files with ofstream

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 พ.ย. 2024

ความคิดเห็น • 71

  • @chriscruz429
    @chriscruz429 4 ปีที่แล้ว +25

    I like how in a lot of your videos you say something like "This is a bit difficult to explain but I will try my best" ,and then go on to do a perfect explanation of the particular subject and make it a super easy to understand.

  • @alexplaytop
    @alexplaytop 7 หลายเดือนก่อน +1

    Every time I hear "our sponsor" its put a big smile on my face, coz it's too CUTE!

  • @Ryan-xq3kl
    @Ryan-xq3kl 3 ปีที่แล้ว +1

    This video is shockingly simple and well spoken!

  • @guitarhax7412
    @guitarhax7412 5 ปีที่แล้ว +35

    Annnnnd that's my 20 for the day. 2 more days and I'll have gone through them all. If we're not friends by the end of this journey.. I'll be sad

    • @codebreakthrough
      @codebreakthrough  5 ปีที่แล้ว +10

      See you tomorrow!

    • @YTBCLIPS01
      @YTBCLIPS01 4 ปีที่แล้ว +3

      I feel you, i practice c++ for 6 hours + every day, Reading,Watching,Writing,Testing all of the above just because i want too.

    • @BattleOfficial_
      @BattleOfficial_ 3 ปีที่แล้ว +3

      @Rudy Makai Ngl but that's creepy af.

    • @PunmasterSTP
      @PunmasterSTP 3 ปีที่แล้ว +1

      I'm your friend, and I've enjoyed seeing a few booms along the way!

  • @YTBCLIPS01
    @YTBCLIPS01 4 ปีที่แล้ว +5

    Caleb, any chance you are down to make like a advanced version or intermidiate version of this series so when we done we can learn even more.

    • @devshorts4184
      @devshorts4184 4 ปีที่แล้ว +1

      yeah, I would like that too

  • @brownshirt1601
    @brownshirt1601 4 ปีที่แล้ว +2

    Hopefully in the future Caleb you will do the Visual Studio version for this as I don’t know how to use Visual Studio Code.

  • @sirskylight7901
    @sirskylight7901 4 ปีที่แล้ว +3

    For Windows, right-click the file and select “Properties”. Then check the “Read-Only” box.

  • @PunmasterSTP
    @PunmasterSTP 3 ปีที่แล้ว +6

    Ofstream? More like off the chain, because this tutorial is unbelievably amazing!

    • @keijuanwhite3538
      @keijuanwhite3538 2 ปีที่แล้ว +1

      go ahead and log off

    • @PunmasterSTP
      @PunmasterSTP 2 ปีที่แล้ว

      @@keijuanwhite3538 Why? Sometimes people think these types of comments are funny, and it's led to some cool conversations along the way.

    • @dhruvdonsahu9972
      @dhruvdonsahu9972 2 หลายเดือนก่อน +1

      @@PunmasterSTP dw about him man, i am having fun reading all of your comments throughout the playlisttt....

    • @PunmasterSTP
      @PunmasterSTP 2 หลายเดือนก่อน

      @@dhruvdonsahu9972 Ah man I'm glad to hear that, and that is exactly what I wanted to happen with my comments! I've been meaning to check out some of Caleb's videos again, so maybe I'll do that this week and leave some more...

    • @dhruvdonsahu9972
      @dhruvdonsahu9972 2 หลายเดือนก่อน +1

      @@PunmasterSTP ohh okii mann ,all the best brother, I am currently on 62nd video , I hope everything goes well , you are an amazing guy brother 🙃

  • @stevewilliams6768
    @stevewilliams6768 4 ปีที่แล้ว +2

    its a marvellous series for me and all thanks to my favourite sir caleb curry

  • @vivekprajapati4787
    @vivekprajapati4787 3 ปีที่แล้ว

    Ending music is a stressbuster

  • @JamesBrodski
    @JamesBrodski 3 ปีที่แล้ว +1

    Really good video! Thank you so much.

  • @abhishekpariyar7895
    @abhishekpariyar7895 4 ปีที่แล้ว +6

    This video is happiness. :) :)

  • @pauloconnor3056
    @pauloconnor3056 ปีที่แล้ว

    absolute legend. Cheers.

  • @jaimeeduardo159
    @jaimeeduardo159 5 ปีที่แล้ว +1

    You are UN GROSO, gracias makia

  • @yasminmontesino241
    @yasminmontesino241 3 ปีที่แล้ว +1

    Question, just to clear up what would std:: ofstream outFile mean?

  • @christianaraujo3447
    @christianaraujo3447 2 ปีที่แล้ว

    great video man. thank you 👍👍

  • @tnkspecjvive
    @tnkspecjvive 3 ปีที่แล้ว +1

    For some reason, I needed to use std::fstream::out to create the file, at least for the first time.

  • @o7.
    @o7. 4 ปีที่แล้ว +1

    I have a question why is c_str() used with in 9:04 is it important or can we not use it

  • @jaakob1128
    @jaakob1128 3 ปีที่แล้ว

    if I wanted to make a file in a specific folder, like the desktop, how would i go around that?

  • @itsMKiAM
    @itsMKiAM 5 ปีที่แล้ว +5

    If anyone is getting an error that reads, "Vector is not a member of std", you'll need to add #include to your std list above. (ex. #include #include ).
    I'm using CodeBlocks. Let me know if this helps anyone!

    • @xuananle4499
      @xuananle4499 2 ปีที่แล้ว

      p/s: for anyone who often forget the name of the lib. You can #include. This works fine in vscode and codeblock but not in Micro Visual Studio(bcuz it is not the standard library)

  • @vegansynths7757
    @vegansynths7757 4 ปีที่แล้ว +1

    This is getting good....

  • @2ksp235
    @2ksp235 3 ปีที่แล้ว

    hello that is awesome i am learning to code and c++ is my base language i ve choosen. How can do like this and encode and decode what i am storing in the file.txt? please i am learning so i really dont know how to do that :) thx

  • @uzzielledelacruz
    @uzzielledelacruz 3 ปีที่แล้ว

    how do you write to a specific line? thank you.

  • @mirnelj9200
    @mirnelj9200 2 ปีที่แล้ว

    whats the name of your theme?

  • @ryanbodily5007
    @ryanbodily5007 3 ปีที่แล้ว

    I am trying to do this and getting a "'file' was not declared in this scope; did you mean fileno" message, is anyone else getting this, if so, any idea what the fix would be?

  • @bodeabbott3261
    @bodeabbott3261 ปีที่แล้ว

    i need to take the output of a void function and write it to a file, except I can't find ANYONE who explains what else you can write to a text file other than simple strings.

  • @thejokercrypto8903
    @thejokercrypto8903 4 ปีที่แล้ว +2

    If you're using visual studio 2019, you can do this:
    #include
    #include
    using namespace std;
    int main()
    {
    ofstream writer("file.txt");
    if (writer.is_open())
    {
    int birds = 4;
    writer

  • @sofhiakianag.doronila776
    @sofhiakianag.doronila776 2 ปีที่แล้ว

    KEEP UPLOADINGGGGGG

  • @Icy_Republic
    @Icy_Republic 3 ปีที่แล้ว

    Great Tut.
    Only fault is LIGHT THEME !!!! 😫

    • @howepellin
      @howepellin 3 ปีที่แล้ว

      whats wrong with that? dark theme is not gonna make you a god of coding

    • @brocklesnarufcchamp1
      @brocklesnarufcchamp1 3 ปีที่แล้ว

      @@howepellin Dark theme is a lot easier for the eyes than a light theme. What made you think dark theme was going to make someone a better coder, lol?

    • @howepellin
      @howepellin 3 ปีที่แล้ว

      Then why is it that most of them see it is a mistake or the programmer's fault just because a person prefers light mode?

  • @Fun-and-life438
    @Fun-and-life438 3 ปีที่แล้ว

    If we want to save user entered data

  • @ruslangogoah9021
    @ruslangogoah9021 3 ปีที่แล้ว

    using namespace std; ?

  • @chadwickcodes6417
    @chadwickcodes6417 3 ปีที่แล้ว

    And people say C++ is harder than Java!

  • @meexists-2527
    @meexists-2527 3 ปีที่แล้ว

    imagine writing using namespace std on the 3rd line instead of having to type std::whatever before everything

  • @JakeShuf
    @JakeShuf 3 ปีที่แล้ว

    Anyone else think Caleb sounds a lot like Seth Green?

  • @sylvesteruchia5263
    @sylvesteruchia5263 ปีที่แล้ว

    Cant name it jellybean , that one is taken.

  • @ayhamghanem3161
    @ayhamghanem3161 3 ปีที่แล้ว

    please use dark mode!!!

  • @shikaku410
    @shikaku410 4 ปีที่แล้ว

    What is this ide

    • @Markofka
      @Markofka 4 ปีที่แล้ว +2

      visual studio code

    • @magicdragon9621
      @magicdragon9621 4 ปีที่แล้ว +1

      Haha I wondered the same thing. You never see anyone use light mode

  • @jamesstark4136
    @jamesstark4136 4 ปีที่แล้ว +1

    Why don't you just use " Using namespace std;" so you don't have to type std:: on every line.
    Edit:
    Also why didn't you have to put #include string ?

    • @tootaashraf1
      @tootaashraf1 4 ปีที่แล้ว +2

      because using namespace std; is bad practice

    • @jamesstark4136
      @jamesstark4136 4 ปีที่แล้ว

      @@tootaashraf1
      example? Its what my professors teach its literally used on almost every video except this one.

    • @tootaashraf1
      @tootaashraf1 4 ปีที่แล้ว +2

      @@jamesstark4136 there's nothing wrong with using namespace std;. It's just bad practice.

    • @roberthoople
      @roberthoople 3 ปีที่แล้ว +2

      I get the bad practice thing, because than you'll have every keyword from std be an active keyword, and that can be a problem in ways, but I have to agree that having to std:: on common used keywords, like cout and cin all the time, is messy and inefficient.
      So my solution is a compromise; for the std:: things that I'm using constantly, I went ahead and gave them "using std::cout;", "using std::cin;","using std::string;"... And I'm going to add "using std::vector;" too, because my app will be using a lot of vectors.
      My code is clean and easy to read this way, and I personally think it's actually a better practice than the so called "best practice" of having to prefix std:: everywhere in your code for such common things, provided you're only doing it for the things that you use a lot.

    • @jamesstark4136
      @jamesstark4136 3 ปีที่แล้ว +1

      @@roberthoople That seems like an okay way to do it, though I think it depends on what we are trying to do and with what resources. I asked my next CS professor and he said that putting std on everything is a waste of time. I don't think using namespace std is the same as say calling and entire library and only needing one function.

  • @janbajana9336
    @janbajana9336 3 ปีที่แล้ว

    I know that is a tutorial for beginners. Maybe would be useful to write who is the target audience. But bigger problem for me is that you teach bad programming practices. Iterate a vector and create copy every iteration?

    • @esmaelhbr
      @esmaelhbr 2 ปีที่แล้ว

      he explained it in the previous videos.

  • @pauliuskubilius2004
    @pauliuskubilius2004 2 ปีที่แล้ว

    This isn't same as whate we are tought in lithuania. on yt it's either arabs with hard accent or americanns with useless teatchings

  • @wz5445
    @wz5445 4 ปีที่แล้ว

    Your video is quite "Curry-ed".
    Sorry I saw your last name and I really wanted to make this joke

  • @janbajana9336
    @janbajana9336 3 ปีที่แล้ว

    I know that is a tutorial for beginners. Maybe would be useful to write who is the target audience. But bigger problem for me is that you teach bad programming practices. Iterate a vector and create copy every iteration?