C++ Programming Tutorial 61 - Reading from Files with ifstream

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

I spent a good hour trying to decipher my CS professor's explanation of how to read in files. You explained it perfectly in five minutes. Thank you!!!

hyrummoses
Автор

Using getline(), how do I read the next name in the file? (In this case, Amy and Susan)
Edit: I found the solution. Use this ----> while(getline(file, input))

abhishekpariyar
Автор

I'm amazed how many videos like this I've watched that still don't show how to read every line in the file to an array. They always stop at just reading the first line. Fortunately I found it in the comments! Still, I've watched a lot of these videos and have learned a lot, thank you!

kathyrice
Автор

Great video, thanks to these I'm easily passing my CS class.

chriscruz
Автор

Files? More like miles, and miles of learning! Thanks again so much for making and sharing these wonderful tutorials.

PunmasterSTP
Автор

The explanation is perfect.Keep up the good work hun

pandorastelevision
Автор

so why doesnt it write anything out for me
i copied line for line what you wrote the only diference was that i used namespace std

nathansayers
Автор

This one has a lot of new info. I get it but will likely need to watch more than once. Very exciting!

vegansynths
Автор

Another issue solved thanks to your videos! You're killin it man!

leonardobernaschina
Автор

You just saved my Life, thank you so much

katharina
Автор

thank u bro just finished my hw cause of u

eriksokol
Автор

Went back to the getline video after watching this!

chadwickcodes
Автор

Hi Caleb, I'm getting some errors on this one and I have the same thing you have; only about halfway through the video so far though. So far I have the while loop and the for loop with all the stuff above, i'm including iostream, string, and vector. I'm getting two problems: "incomplete type is not allowed on std::ifstream file (squiggle is under the word file). And then at while(file >> input) I'm getting "no operator ">>" matches these operands" and I'm compiling using C++11 so I'm not sure what's up. I've tried restarting a few times too.
Thanks!

kdtallllll
Автор

what does the for(string name : names) do? Have never seen that before. Thanks in advance! :)

eliaspfeffer
Автор

why not use namespace std? eliminate the std::

kyleryxn
Автор

anyone using visual studio 2019,
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
ifstream reader("file3.txt");
int a, b;
if (reader.is_open())
{
reader >> a >> b;

cout << "Sum of variables a and b is: " << a + b << endl;

}
else
{
cout << "Error." << endl;
}


reader.close();
system("pause");



return 0;
} //All you need to is go to the folder and make a new text document. Right click, press new and click text document and name it whatever you want. I named mine file3 because of my code. I wrote 10 and 20 in the file and saved and closed the file. When you run the code, it should output when I did cout. "Sum of variables a and b is: 30."

thejokercrypto
Автор

Hi, what theme are you using for VS Code?

nljaded
Автор

I'm working on an OpenGL project. When I try to use fstream to upload my shader, it returns one line of randomly selected text from the file. Anyone know what's going on?? Thanks.

gothicknight
Автор

Can you pls help me design the code which enables us to store the pin, accountnumber and balance of more than 2 users In file using filehandling concept c++.

malaikanazar
Автор

If it were a boolean, it would be so true

Kim-byuy
join shbcf.ru