Your File Handling course saved me, thank you brother! I'm in the 2nd year in Computer Science and haven't understood file handling yet. After your course i don't have any doubts. Thanks for this amazing tutorials, keep the good work !
@LearningLad Жыл бұрын
glad my video helped you. keep learning :)
@forrealkye2 жыл бұрын
Dude you just helped me with an assignment I couldn't find how to use .read() to assign values to an instance anywhere else, thank you so much!!!
@LearningLad2 жыл бұрын
Pleasure
@samhackett41818 жыл бұрын
Thank you! This is the clearest explanation of this topic I've found.
@truthworld3d7 жыл бұрын
Learning Lad Rocks!! Anil Shetty is awesome!! Thank you so much... you saved my life.
@LearningLad7 жыл бұрын
:)
@vikaskamble34313 жыл бұрын
Thank you so much brother for this series... this series helped me a lot in my project..
@LearningLad3 жыл бұрын
Pleasure
@MsRedCatastrophe9 жыл бұрын
Thank you so much! This cleared up so many problems I was having. I was able to finish my cs homework in ten minutes thanks to you. Looking forward to watching more of your videos.
@LearningLad9 жыл бұрын
Caitlin A great! i'm glad that my videos helped you :)
@rajanibhatt54157 жыл бұрын
just too helpful in the exam time please continue these types of vedioes
@LearningLad7 жыл бұрын
sure :)
@CreamCity7 жыл бұрын
in this program how would you read from the middle of the file? how would you change file.seekg(0) to file.seek(1) and still have a functional program?
@emcemimotionandcontrol55543 жыл бұрын
You can't. It's a serial of objects stored in a file.
@richarddanladi98028 жыл бұрын
Great tutorial sir. I finally got it.
@LearningLad8 жыл бұрын
Awesome. Thank You :)
@jackiechan84599 ай бұрын
amazing tutorial!
@LearningLad9 ай бұрын
Thank you!
@zakariachahboun8 жыл бұрын
amazing tutoriel ! simple and short thank you sir
@LearningLad8 жыл бұрын
my pleasure :)
@digimikeh3 жыл бұрын
Thanks Anil..
@LearningLad3 жыл бұрын
Pleasure
@ishan78247 жыл бұрын
Why there is a need of type casting object name?
@jamunabaskar75377 жыл бұрын
thanks a lot, your videos are are incredibly helpful for me to understand the concept thank you
@LearningLad7 жыл бұрын
my pleasure. keep Learning :)
@VijaydBazz8 жыл бұрын
You are the best bro..very nice and detailed explanation...other tutorial sucks!!!
@LearningLad8 жыл бұрын
Thank you :)
@VijaydBazz8 жыл бұрын
Welcome...:)
@AbhishekSingh-yh7ce4 жыл бұрын
Awesome videos on C++ to learn as a noob programmer. Enjoying my time with these great videos during this great lockdown. #ThanksLearningLad❤️
@gomesluis4010 жыл бұрын
thank you very much.....this clears so many doubts :)
@LearningLad10 жыл бұрын
luis gomes glad that my video helped you :)
@4Y0P8 жыл бұрын
Thank you very much! (: Helped me out
@LearningLad8 жыл бұрын
+Whims glad to hear that . happy Learning :)
@anmolbehl85727 жыл бұрын
Sir it's not working for me in code blocks
@alg0rithm19 жыл бұрын
How portable is this? Can I treat the binary file as a library and expect to work on a different computer? Thanks
@bonbonpony5 жыл бұрын
No, you can't. The technique presented here is not portable, mostly due to endianness. Different platforms use different order of bytes in a multi-byte number, so just reading them into a struct happy go lucky may easily break on a computer with a different endianness. Also, compilers can use padding between the fields of data structures to make memory accesses faster, leaving some spaces between them. In that case, reading data from file into the memory of the object and interpreting them as the object won't work either, because everything will get corrupted if the actual layout in memory is different than in the file. You can kinda avoid that by packing your data structures in memory (using `#pragma pack`), but then it may damage the memory access speed because the fields won't be properly aligned in memory and the CPU will have to make two memory accesses (or more) instead of one to get the entire piece of data. Data in memory should be aligned, and data in binary files should be packed. Simple as that. So you need to come up with a procedure of converting the data back and fort from/to packed representation during reading/writing. And make sure you read the bytes of a number in correct order, matching the endianness of your platform. Then the code will be fully portable.
@carlosgarciavigoa79375 жыл бұрын
@@bonbonpony Excuse Bon Bon, but every time than I find a video about reading and writhe file or binaries, you always make a complaint about is not correct or is wrong. So now I don't know is this correct or not. I know C++ and I'm in the process to make thing correctly. Can you explain how can we do it the right way? PLS!
@bonbonpony5 жыл бұрын
@@carlosgarciavigoa7937 And?
@carlosgarciavigoa79375 жыл бұрын
@@bonbonpony Can you do a video on how to do it?
@bonbonpony5 жыл бұрын
@@carlosgarciavigoa7937 I don't have an equipment, but I don't think a video is necessary. I can explain it in short here. First the padding of structures: As I said, they should remain aligned in memory, because that's how the CPU can access their fields faster, but remain packed in binary files, because that way they take less disk space. So you have to come up with a way of converting one representation into another (which is a good thing anyway, because it may isolate your code from the actual binary representation, which may then change without affecting the code). If you read one field at a time, you have this problem solved. Except for the endianness, so let's get into that now. One way do do that is by reading one byte at a time, because endianness don't matter for bytes, only for multi-byte sequences (i.e. numbers). So if you have to read some multi-byte sequences, you can read them one byte at a time and then put together in the correct order by bit shifting and masking. (Or you can use a bit field and let the compiler do the bit fiddling for you, but this is a bit less reliable due to sloppy standards and their implementations.) It's good to test the endianness of the platform before reading any multi-byte sequences. You can do that by writing some byte pattern in a known order into memory, and then reading it back as a multi-byte number, then compare which of the possible numbers you got. (Many file formats use "magic signatures" in the beginning of the file for that very purpose.) For example, if you write 0xCA into the lower address and 0xFE into the higher address, and after reading it back as 16-bit number you got 0xCAFE, then your platform is big-endian. If you got 0xFECA instead, your platform is little-endian. You can even make it a compile-time test if you don't want to branch at runtime, and then let the compiler generate one of two versions of your code depending on the endianness of the platform. There are also some library functions for byte swapping and detecting the endiannes, so you can use that as well.
@khurshidernazarov8095 жыл бұрын
There was no need to create classes, you could save everyone's time. But anyways thanks.
@LearningLad5 жыл бұрын
thanks for the suggestion. will be remaking this series soon. i will keep this mind.
@gauravmangal51915 ай бұрын
Hello, I just liked all of your videos from this playlist on File management. they are good, other then you trying to throw English accent which was annoying🤣🤣, Everything was great and very helpful. Thank you for your time.🙂😊
@LearningLad5 ай бұрын
Stupid me 😀
@p9malino2677 жыл бұрын
Your tutorials are very good but goodness me, improve that code layout!
@hafidzrazman53656 жыл бұрын
can you please explain why we need to use person(char *name,int age) ?? why we need to use pointer there? enlighten me please
@sarathelayadath25654 жыл бұрын
will it work if there is a variable size memeber in the class ?
@nutcrackzengine12328 жыл бұрын
Hi LearningLad, how can i use this awesome method to read an existing file without writing to it first? thanks for this awesome tutorial :)
@EBKCS_SamarthGoyal2 жыл бұрын
Sir instead of storing name as a char array if I want to take name as string class object then how to store name in a file ?
@sahelahmed00938 ай бұрын
Damn this saved me
@LearningLad8 ай бұрын
glad my video helped you :)
@ДимаКимсыщик8 жыл бұрын
i got it finally ))). it is read functions specficity
@wasiimo8 жыл бұрын
(char*)&anil just means we're going to have a char pointer pointing to the byte data which make up anil.
@baczek402 жыл бұрын
thanks bro!
@MrHmm-cv6gs5 жыл бұрын
you just made the tutorial difficult using constructer, though there was no need for that
@dmitryalexandersamoilov4 жыл бұрын
but i learned more about constructors!
@MrHmm-cv6gs4 жыл бұрын
@@dmitryalexandersamoilov great👍
@shahrukhtramboo67817 жыл бұрын
sir i am getting an ISO file as output. and it shows INVALID IMAGE FORMAT. i cant open it. why is that . please help
@ajw178 жыл бұрын
Can you please explain how the (char*)&anil works? What exactly is happening here? Is this a cast?
@konstantinosdimitropoulos35337 жыл бұрын
Dude i did not understand that either
@jakethewoz4 жыл бұрын
The read() and write() methods both read/write one byte at a time. In order to write something bigger than a byte, you have to cast it as a number of bytes. The code is basically saying write('anjali in the form of bytes', 'the size of anjali in bytes').
@Kromush19957 жыл бұрын
Can someone please explain me why it crashes when it reaches the exit bracket of else branch? Here's the code, in which i create a binary file, write something in it, extract the content into a different string and then displays the output to console. void main() { fstream file("BinaryTest.bin", ios::binary | ios::in | ios::out | ios::trunc); if (!file.is_open()) { cout
@jacksquirrel20016 жыл бұрын
{ string content = "First line in binary file."; // 1) You can't take the address of a string and // use it to save its contents - you need to use // the data() member function, which returns the // address of the first character in the string. // Note that for string, data() returns a char*, // so there's no need for the (char*) cast: file.write(content.data(), content.size()); //file.write((char*)&content, content.size()); file.seekg(0); // 2) The outputContent string is empty, so // there's no place to read the contents in // to. You need to allocate space so that // all of the expected data can be read. This // can be done using the string constructor. // The following statement initializes a string // with content.size() characters all set to 0. string outputContent(content.size(), 0); //string outputContent; // 3) You need to make the same change // as 1) and use data() instead of &. file.read(outputContent.data(), content.size()); //file.read((char*)&outputContent, content.size()); cout
@maulinshah52758 жыл бұрын
hello sir, while doing this program I have an error that [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings] plz give me possible solution..
@astudent92065 жыл бұрын
I guess you are using Linux...I think there's a flag for suppressing warnings...I don't quite remember the syntax...You can google it :)
@rahulroyjannapurashivakuma77675 жыл бұрын
Awesome tutorial. If we declare Person class data member 'name' as string, then anil.change() function is also changing the name of sunil to "xxxx" but not the age. Please clarify. TIA.
@ДимаКимсыщик8 жыл бұрын
I don't get it. WHY? it saves an adress of object, then it copies the adress to another object, bu they are different?
@stovegamesgames69174 жыл бұрын
Where is the documentation for the libraries used?
@GurpreetKaur-pn7vk6 жыл бұрын
tell me the significance of cin.get(ch)?
@DickheadEnterprises6 жыл бұрын
What happens if we exclude ios::in and ios::out? Isn't an fstream already implied in and out
@bonbonpony5 жыл бұрын
`ifstream` implies `ios::in`, while `ofstream` implies `ios::out`.
@lavanyalavan80576 жыл бұрын
The computer screen was not clear.
@LearningLad6 жыл бұрын
really sorry about that.try to watch it in 1080p. in some video's we have this issue and we have solved this in our latest video's :)
@hemanthmusic19336 жыл бұрын
Hi, I have a doubt can you please help me
@muhammadusmanghani16487 жыл бұрын
Why its displaying data twice?
@gosnooky7 жыл бұрын
Good tutorial, your code is a mess, though.
@ruchisolanki47557 жыл бұрын
Voice clearity is less
@LearningLad7 жыл бұрын
yes. i can understand. we have solved this problem in latest video's :)
@bonbonpony5 жыл бұрын
This approach is very bad, because it ignores the endianness of the platform (the order in which bytes are stored in a multi-byte number) and data layout in memory (packed vs. unpacked), and therefore it is higly unportable and prone to data corruption. Don't follow these advices in real production code!
@bonbonpony5 жыл бұрын
@Peterolen Standard integer size will solve only the packing problem (and even that only partially, because there still could be some padding between them that will break the compatibility of the binary structures), but not the endianness problem. Bytes of a number can still come in the wrong order.