C++ Tutorial - 23 - Writing on Files

  Рет қаралды 166,903

thenewboston

thenewboston

Күн бұрын

Пікірлер: 157
@anapaola660
@anapaola660 2 жыл бұрын
I recently found your account and I began binge-watching these videos for a refresh on C++ Thirteen years later and this is still extremely helpful. I feel as if I just struck gold. Thank you!
@kevinaugustine
@kevinaugustine 16 жыл бұрын
Thanks much, Your tutorials are extraordinarily helpful for me. I am trying to navigate my way through my self taught program to learn about computers and coding- your tutorials of C++ and How to Build a Computer are greatly appreciated. I am indebted for your efforts, Kevin Walsh Chicago Peak Oil
@Tom_Armstrong_
@Tom_Armstrong_ 14 жыл бұрын
Excellent tutorials, FAR easier to understand than the others I've been watching. Thanks again.
@medatre4792
@medatre4792 8 жыл бұрын
Hi! Thank you sooooo much for this tutorial. I was on the verge of tears because I could not figure out how to "link" the text file I created. Now that I know a new one gets create it if it does not exist, I can tackle my project that is due in two hours!!!!
@christophermwenya1484
@christophermwenya1484 7 ай бұрын
Almost cried as well 😂
@LuparaAndBianca
@LuparaAndBianca 11 жыл бұрын
Tons of games have files in the folder they're in that are text files. These text files are just like part of the program but since they can be edited in real time using f.ex. notebook it means that the user can open the file, change something and the game will change accordingly. A prime example is any Minecraft server with a "server" txt document. There are a bunch of stuff you can change just by writing true or false in that document and the game will change. This is really useful.
@thenewboston
@thenewboston 16 жыл бұрын
dont worry ill be adding another contest soon, but there are 2 other contest going on now!
@Trolld
@Trolld 6 жыл бұрын
come back plllz
@FrankC656
@FrankC656 5 жыл бұрын
Bucky! Bro you should’ve seen the look on my face when I did this and it actually worked. I didn’t doubt you, just figured some how it wouldn’t be so easy.
@Jonko192
@Jonko192 14 жыл бұрын
thanks man, very clear explanation that i couldn't find that simple on internet. Your best tut, keep up the good work
@joanzninja4890
@joanzninja4890 3 жыл бұрын
Because of you im probably gonna have extra points in my project. Thanks bro.
@bensewards
@bensewards 14 жыл бұрын
one way to find out if you created a new file is to go to start, search, and search for the name of the file you created and if its there, there should also be any text you may have written on to the new txt file aswell! pretty cool!
@kalef1234
@kalef1234 9 жыл бұрын
you're so good at explaining things ina short amount of time. Thanks!
@denezt
@denezt 15 жыл бұрын
I like this tutorial, however I also had a small problem finding the file. But as a note you should look in your file where ever your programs are being saved to. Thanks Bucky...You rock!!! \0/
@ss4pandaman
@ss4pandaman 15 жыл бұрын
thanks man you realy saved my butt i was going crazy i though my system was error or somthing then i read your note and you helped me you rock thx
@iiN1GH7M4R3ii
@iiN1GH7M4R3ii 6 жыл бұрын
Worked well for me. I'm on Windows and Visual Studio 17. Thank you Bucky, you are very helpful!!!!!
@BeyondAIR15
@BeyondAIR15 6 жыл бұрын
where did you find the file?
@iiN1GH7M4R3ii
@iiN1GH7M4R3ii 6 жыл бұрын
iNfam0usColors it's in Notepad. I found it by going to file explorer and going to My PC. Then I typed in the name of the file, waited a minute then it came up.
@coolzidedown
@coolzidedown 14 жыл бұрын
@ElPeester The file gets created in the workspace folder that the .cpp file is in. buckys was probably on the desktop
@RondellKB
@RondellKB 12 жыл бұрын
finall a good tutorial on file hanling in c++, thanks
@Ifindthevids
@Ifindthevids 13 жыл бұрын
Took me a couple of tries, but I understand this now :)
@drcvagos-iu
@drcvagos-iu 9 жыл бұрын
great tutorial series, thank you so much!
@karmincernescu
@karmincernescu 14 жыл бұрын
i have one question: what does the "using namespace std" do? i do some c++ programming at school, but i've never used or heard about this; thanks in advance, and thanks for sharing your c++ knowledge with us ;)
@Harikaserap
@Harikaserap 12 жыл бұрын
Thanks a lot. I did it by DownloadHelper plugin for firefox.
@notfavoritemartian
@notfavoritemartian 4 жыл бұрын
Nice and simple, have my like
@Ardrin2889
@Ardrin2889 13 жыл бұрын
So, is there a list of the ways you can edit text such as " " for new line?
@AlgeriaSon
@AlgeriaSon 15 жыл бұрын
Please take a look where your folder containing Dev-C++ is located. It should be there
@L3v1Te
@L3v1Te 13 жыл бұрын
One word "awesome!"
@MireilleNamar
@MireilleNamar 9 жыл бұрын
at 5:52 , this a problem i'm facing , is there anway I can add lines to a file that already has text ??
@johnnyc130
@johnnyc130 15 жыл бұрын
This looks like it be very helpful, yet i havent read anything on it. Thanks for the tutorial.
@SajanPrasad
@SajanPrasad 9 жыл бұрын
Bro, by giving this, it goes and makes a file in the default place of C++. But how to make c++ store that txt or object to our specified location.
@HardkoreRocker
@HardkoreRocker 13 жыл бұрын
hey boston, i been working on a program for a while and im having some trouble, i need to create a file by the name thats inputted by the user......how do i do that??
@ducarazvan94
@ducarazvan94 15 жыл бұрын
when will the next c++ tutorial come up?
@tHaH4x0r
@tHaH4x0r 14 жыл бұрын
Hello, iam not new to c++ but i have a question, what if you dont want to erase the previous "version" of the file but want to continue on the bottom ? Thanks in advance tHaH4x0r
@carstorm85
@carstorm85 14 жыл бұрын
@Universaldark The same thing was happening to me. However when I ran a search for the file it was found in the same folder as where I had the original file saved (The c++ file)
@Harikaserap
@Harikaserap 12 жыл бұрын
Where I can download the all the videos? Thanks,
@button4boy
@button4boy 12 жыл бұрын
If you want to specify where to put the new file, you can write the path in the string text like this: myFile.open("C:\\Users\\Owner\\Documents\\University Stuff\\Advanced Software Development\\Assignment 2\\DataFile\\SolvedPicture.txt"); Make sure to put double backslashes in as otherwise the compiler will see them as commands etc...
@AlphMarco
@AlphMarco 13 жыл бұрын
@EMOxCORExAT try to right click it and open with and select any windows included text reader program, such as: notepad or worpad, try not to use word or so, cause the text may be different or not showing properly.
@tadas156
@tadas156 12 жыл бұрын
What sintax to put text files in other directories ? :)
@johnnyc130
@johnnyc130 15 жыл бұрын
How can you make a program run in the background. I want to try to use this tutorial to make a keylogger.
@0oBadboyo0
@0oBadboyo0 14 жыл бұрын
@coolzidedown True, found it in the workspace folder thanks.
@BeatificStar1985
@BeatificStar1985 12 жыл бұрын
Hey Bucky!! thanks for taking out time and putting efforts in making these tutorial !!! Kudos !!! Do you know how/where to define a path for the file created through a c++ code. Thanks again @@ !! keep up the good work!! cheers mate !!!
@priscusemmanuel8403
@priscusemmanuel8403 2 жыл бұрын
is there anyway you can help me how to do this on a Xcode?
@surajitdas2505
@surajitdas2505 6 жыл бұрын
Very Helpful ..thanks :)
@artteaparty
@artteaparty 8 жыл бұрын
What if I have a txt like this 1 2 4 0 5 6 And I want to define 2 int that each int gets one column (like x gets 1, 4 , 5 and y gets 2, 0 , 6) I need it for polynomials. i.e x is coefficient and y exponent
@ss4pandaman
@ss4pandaman 15 жыл бұрын
how do i get to your website the link brings me to a video wasup with that i want to get that code you said i can get
@JKTCGMV13
@JKTCGMV13 14 жыл бұрын
Is it supposed to open the file, or just create it?
@chernobila
@chernobila 15 жыл бұрын
hello sir are you going to post more C++ tutorials? Please do Thank you
@zetarobot
@zetarobot 14 жыл бұрын
@coolzidedown wat if the cpp file is not there?
@pegu06
@pegu06 16 жыл бұрын
Does this method only work for creating text files?
@ChiefOScience
@ChiefOScience 13 жыл бұрын
Hey, why isnt this video on your website?
@Universaldark
@Universaldark 14 жыл бұрын
I know this tutorial is so old, so I may not get an answer, but this never works for me. I don't know why. Has something changed with C++ in a year that causes this to not work? It's put in exactly, even brings up the command prompt, but never creates any kind of a text file. I basically typed everything in word for word, and no matter how I do it, it never brings up any text file....
@gameglithcfinder7731
@gameglithcfinder7731 7 жыл бұрын
what compiler do you use?
@rockydasha
@rockydasha 14 жыл бұрын
new C++ Tutorial!!
@kikegoleador315
@kikegoleador315 7 жыл бұрын
How can I get the user to input the location of the file along with the file name and type?
@juliakaeppel8762
@juliakaeppel8762 9 жыл бұрын
This is a great tutorial!
@111222333444R
@111222333444R 12 жыл бұрын
how can you do this on xcode? I don't think it's the same code. I tried it but it didn't work. :/
@thatsmamaluigitoyou1
@thatsmamaluigitoyou1 13 жыл бұрын
is there a way to change the directory that the file will appear in other than just doing system ("cd")
@Yizak
@Yizak 13 жыл бұрын
Can I specify the location of the file?
@linkinl1
@linkinl1 13 жыл бұрын
is that for new line like the endl?
@Marty70072
@Marty70072 13 жыл бұрын
it didnt create a new file for me :/ but it ran it.. (there were no errors)
@abboudashkar3804
@abboudashkar3804 4 жыл бұрын
same
@FINEDIAMOND
@FINEDIAMOND 13 жыл бұрын
How do I do this using Xcode on a Mac? I tried using "newfile.txt", but it failed because macs don't use .txt files. I tried "newfile.rtf" using Rich Text Editor, which is used to write notes in TextEdit, but it failed as well. I even tried calling one of the text files which I have saved on my computer to test it, but this didn't work either.
@TH3L44R123
@TH3L44R123 13 жыл бұрын
what does this mean: C:\users\*****\desktop\happyb~1.EXE the NTVDM CPU has encountered an illegal instruction CS:0572 IP:0103 6c 75 64 65 Choose 'close' to terminate the application ?
@papano12
@papano12 15 жыл бұрын
I had to save as new.cpp in the desktop location for it to work. U will get 3 new desktop icons if u save it this way. 1 of them will be the txt file. and the other 2 will be the dev project and the cmd prompt result.
@R4G1NG
@R4G1NG 13 жыл бұрын
also how can you make it only change one thing not all of the file as it will overwrite the previous thing it you just put the thing in you want to change..
@RaamAnkka
@RaamAnkka 14 жыл бұрын
So i know this is like not relevant but how could this be use of? could you use it on games maybe for the save file?
@stickmakerman
@stickmakerman 14 жыл бұрын
hey dude, i got problem here. i am making a math quiz and i got the main stuff to work, but the problem is that when i am writing the points into a file with the name of the person, i want it to add it instead of replacing what's in there already. can you help a fellow subscriber? :c
@leezhijiang
@leezhijiang 10 жыл бұрын
Hey, when I run the program again, I want it to print on the next line instead of replacing the current one back. Is it possible ?
@mrskywalker6114
@mrskywalker6114 5 жыл бұрын
Best thing to do if you want to add to existing file is to read what's currently on it, store it in a variable(s) then add it back to the file when you overwrite it. It seems tedious work but that's how it works.
@nilufargh
@nilufargh 10 жыл бұрын
Hey what is an object exactly? thanks
@beterhans
@beterhans 7 жыл бұрын
Please how to write UTF-8 text to file.
@10000years
@10000years 13 жыл бұрын
i follow every step but couldn't find the txt file anywhere
@KelechiIkegwu0
@KelechiIkegwu0 12 жыл бұрын
Incase anyone has figured this out yet. The file is located where you store your cpp files. So if you didnt save on desktop it most likely will not be there :D
@princesscatesambajon1553
@princesscatesambajon1553 7 жыл бұрын
hi can i asked help? i dont know what to do with my program :(
@GNSstudios
@GNSstudios 15 жыл бұрын
i can't frekin get it to work nothing is appearing on my desktop
@bigdogg4lyfe
@bigdogg4lyfe 10 жыл бұрын
Thanks Bucky! U da man
@Ifindthevids
@Ifindthevids 13 жыл бұрын
@EMOxCORExAT This confused me too, but it doesn't open the file, it just makes one, he said in the video that he was opening the file.
@talkingfractal
@talkingfractal 15 жыл бұрын
The most common thing bucky says is "Gonna wanna do" XD
@sunnydeoloo
@sunnydeoloo 13 жыл бұрын
great sam keep doing
@Ardrin2889
@Ardrin2889 13 жыл бұрын
open() doesn't literally open the file. By "open" it means to perform input/output operations on it. So it kind of opens it, but it doesn't display it :3
@Guildwars55
@Guildwars55 15 жыл бұрын
lol but thats one of the reasons we love him
@TheSyphon666
@TheSyphon666 15 жыл бұрын
thank you ^.^
@MICHAELZHANG1997
@MICHAELZHANG1997 13 жыл бұрын
@savanath it's wherever you put your .cpp file
@R4G1NG
@R4G1NG 13 жыл бұрын
thank you! really needed this as i needed to help my mate edit a file and he didnt know what to change so i just sent him the .exe and he ran it and it did it for him :D if that made sence
@ayeshahabib3060
@ayeshahabib3060 3 жыл бұрын
Sense *
@GNSstudios
@GNSstudios 15 жыл бұрын
he uses namespace. wouldnt it be easier to just not include the std: part and just do the cin.sync(); dont get angry at me in new to this juts wondering
@GNSstudios
@GNSstudios 15 жыл бұрын
Thank you.
@thebeacongamer7286
@thebeacongamer7286 8 жыл бұрын
That's simpler than saving a file in Java!
@lifetycoon101
@lifetycoon101 13 жыл бұрын
umm.....i did the exact same program except i changed the gave the text a bizarre name and it doesent work?? can any1 help?!
@TheSyphon666
@TheSyphon666 15 жыл бұрын
whats a memory leak?
@davemaze1989
@davemaze1989 15 жыл бұрын
hello everyone. i cant get it to work. i nid ur help i cant get it to work on my pc. no file is been created. i have followed the steps all ova and ova, but it aint working. thanks.
@andreuplata
@andreuplata 14 жыл бұрын
eyyy, anyone knows how to use the app option to append text instead of overwriting the previous text?? I have tried but my text turns into []
@saigaldutt5757
@saigaldutt5757 11 жыл бұрын
ok it did open but on a different programin language it opend in Pascal instead of note pad...whats wrong
@DanielsThierry
@DanielsThierry 6 жыл бұрын
Why the hell didn't you show how to insert the next sentence under the previous one?
@deniscimic6961
@deniscimic6961 6 жыл бұрын
Just do myfile.open("newfile.txt", ios::app)
@Niki-ue6fk
@Niki-ue6fk 4 жыл бұрын
2020 still ...🌟
@Qazqi
@Qazqi 12 жыл бұрын
cout writes to stdout. It's possible to redirect that to a file, so you can't always count on it being output to the console if the person running the program chooses otherwise. And while that is a common name for the operator, it's still the left bit shift operator, just overloaded for the purpose of output. That use has been so widespread, though, that the extra name stuck quite well.
@Saunapa
@Saunapa 12 жыл бұрын
this code didnt create a new file. it doesnt do anything.
@deceit1991
@deceit1991 14 жыл бұрын
Great videoo !!
@ussul6524
@ussul6524 7 жыл бұрын
system -- not declared. Seems that you used #define
@dominykaszakrys3373
@dominykaszakrys3373 6 жыл бұрын
where the file is created, it is not on desktop
@0xfeedcafe
@0xfeedcafe 6 жыл бұрын
In the same folder that is your .cc/.cpp code stored
@Loosner202
@Loosner202 14 жыл бұрын
@eeemiel You are right , thanks ! :D
@kdwqrx
@kdwqrx 16 жыл бұрын
yes you can create games with it. but there are other programming languages that can too.
@quaget
@quaget 12 жыл бұрын
yeah, why don't the game software developers just come over to your house, open up notepad, and type the error report in there when your game crashes?
@kigesui
@kigesui 14 жыл бұрын
this is magic....
@mjsdabeast
@mjsdabeast 15 жыл бұрын
you used for a new line for the first time in all of the tutorials lol
@dsadsa9881
@dsadsa9881 13 жыл бұрын
@EMOxCORExAT same, myn saved it in the dev cpp file
C++ Tutorial - 24 - Reading From a File
8:00
thenewboston
Рет қаралды 477 М.
Reading/Writing structs to files (aka Serialization)
14:41
CodeVault
Рет қаралды 77 М.
GIANT Gummy Worm #shorts
0:42
Mr DegrEE
Рет қаралды 152 МЛН
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 576 М.
Output File Streams in C++ (Writing to Files)
13:47
Programming with Dr. Hayes
Рет қаралды 39 М.
File Access Basics | C Programming Tutorial
24:05
Portfolio Courses
Рет қаралды 107 М.
C++ File Input and Output
10:21
Shmeowlex
Рет қаралды 70 М.
C++ Tutorial - 2 - The Basic Syntax and Functions
9:33
thenewboston
Рет қаралды 380 М.
Buckys C++ Programming Tutorials - 65 - Tips for File Handling
6:35
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 849 М.