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))
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!
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!
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.
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++.
If I'm not mistaken the destructors for file streams take care of that so unless you want to make sure it's closed before the end of the scope you don't need to call 'close'
u need to to put the getline before the while. then add another getline after the cout: string wholeline; getline(myfile, wholeline); while (myfile) { cout
What if I ask the user to input the name of the file they want to open, then I put that name inside a variable? How do I then open the file using the variable?
I don't know how to automatically detect the input file name in a directory, and I'm not sure if that's possible, but you can also just make the file name a variable, such as "string filename" and then use cin >> filename; then you open the file using ifstream file (filename)
anyone using visual studio 2019, #include #include using namespace std; int main() { ifstream reader("file3.txt"); int a, b; if (reader.is_open()) { reader >> a >> b; cout
It's 7/28/21 and this video now has over 60k views, and I'm glad about that. It actually has one of the highest view counts out of the videos in this part of the playlist that I've seen so far.
@@moistness482 Yeah and I'm hoping this playlist gets even more views over time. I tutor some computer science subjects, one of them being C++, and I try to share links to relevant videos and other resources. I've already linked a few times to this playlist, and I'm planning to continue doing so.
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!!!
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))
It prints everything in one line...
Solved it. You just have to add a "
" at the end of the input
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!
(I should have said 'vector' instead of array!
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
Great video, thanks to these I'm easily passing my CS class.
Files? More like miles, and miles of learning! Thanks again so much for making and sharing these wonderful tutorials.
The explanation is perfect.Keep up the good work hun
This one has a lot of new info. I get it but will likely need to watch more than once. Very exciting!
Hi, what theme are you using for VS Code?
Another issue solved thanks to your videos! You're killin it man!
what does the for(string name : names) do? Have never seen that before. Thanks in advance! :)
It gets the values of each index in the vector/array opposed to having to do vector[i]
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!
#include
You just saved my Life, thank you so much
why not use namespace std? eliminate the std::
thank u bro just finished my hw cause of u
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.
how do you filter commas? like a comma separated line, each line must store info into a character or int
Amazing video, thank you a lot!
Went back to the getline video after watching this!
for the first tutorial, if I don't use the vector, I use the dynamically-allocated array. How do you do that?
put every single character from the file to that array
how do i insert the text file to visual studios?
For me, i cannot type the condition file >> input in the while loop, it gives me an error. It say no operator matchs this operand.
I have the same problem, did you solved it?
i solved, i used std::ofstream file instead of std::ifstream
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++.
Nice job man!
How do you print out the second line, please?
Did you leave out "file.close" function? I'm still learning but c++ book had that. the book doesn't offer an active demonstration like video does.
You should always close the file. Maybe he forgot it but for this video purpose it was great! He is a crack.
If I'm not mistaken the destructors for file streams take care of that so unless you want to make sure it's closed before the end of the scope you don't need to call 'close'
Theme?
ifstream myfile ("Jacob.txt");
string wholeline;
while (myfile)
{
getline(myfile, wholeline);
cout
u need to to put the getline before the while. then add another getline after the cout:
string wholeline;
getline(myfile, wholeline);
while (myfile)
{
cout
Thanks for the great work!
What if I ask the user to input the name of the file they want to open, then I put that name inside a variable? How do I then open the file using the variable?
0:00 is exactly what you are asking
how would you code it to where it can automatically detect the input file name without hardcoding the name of the file into the program?
I don't know how to automatically detect the input file name in a directory, and I'm not sure if that's possible, but you can also just make the file name a variable, such as "string filename" and then use cin >> filename; then you open the file using ifstream file (filename)
how to get the second or third line only? which mean I only want either Amy or Susan to be display on screen
Use fseek()
anyone using visual studio 2019,
#include
#include
using namespace std;
int main()
{
ifstream reader("file3.txt");
int a, b;
if (reader.is_open())
{
reader >> a >> b;
cout
Thanks mister
How do you load a csv file ?
Amazing video!
U saved me a few hours with this lol
I'M BACK BABY... BOOM
If it were a boolean, it would be so true
the first tutorial has about 30k views while this only has about 1k views. wow
It's 7/28/21 and this video now has over 60k views, and I'm glad about that. It actually has one of the highest view counts out of the videos in this part of the playlist that I've seen so far.
@@PunmasterSTP Quite amazing
@@moistness482 Yeah and I'm hoping this playlist gets even more views over time. I tutor some computer science subjects, one of them being C++, and I try to share links to relevant videos and other resources. I've already linked a few times to this playlist, and I'm planning to continue doing so.
what IDE is he using in this video?
Henry Danger visual studio code
6:06 yeah it would be truuuuuuee :D
thank you so much bro, greetings from germany :)
Nice video
using namespace std;
Sheesh, file handling is a lot simpler in c
3:12 "tacos" es racista
Tacos are racist? Lol
not working
Jesus thats zoomed in
gg