Комментарии:
I copied your code and it didn't work, I found out the problem was that I did not give the program the specific path to the file. So if you are stuck just change "input.txt" to the full path name :)
ОтветитьWhere, exactly is the file located? I did not see the specified location in the program!
ОтветитьWhat if I wanted to read the entire text file with a while loop but instead of storing the entirety of a file in a single variable I wanted to make each line, or each thing separated by white space be stored in individual variables. Say you have a text file with a list of names separated by white space (not worrying about the first and last name being separated by white space). I want to read the entire file and have string name1 be the first name, string name2 be the next name and so on how would you accomplish this?
ОтветитьI want to be able to read multiple lines how can I accomplish that?
ОтветитьIt is difficult to make a program that can unpack the content of a data container file that is less then 1 MB ? How to start writing such a program? Thank you in advance
ОтветитьOmg, I’m doing my 1st semester cpp final and had some ideas that’re way past my expertise but thanks to this I think I can actually get it! Tysm 10000/10 channel def the best YT Prof I’ve ever seen! ❤❤❤
Edit: Def just got my sub!
That's amazing. You are way more coherent than my professor.
I do have a question (if you still take any) how would I read both an int and a string piece of information such as "123 abc"? Something like that. Can you read them separately? Thank you!
hi professor, what should I do if I want to read the text file with different data type. for example the file contains the data of student number (char type), student name (string), and test score (integers) in each row. thank you
ОтветитьDude you are an actual life saver I've spent the good part of two hours trying to figure out how fstream iterates. Now that I get that it works kinda like the console I feel kinda dumb for overcomplicating it for myself.
ОтветитьGood day, Prof! May know what application you are using for writing the program? Thank you in advance
ОтветитьGood day Professor! it is a great tutorial video. However, i have some question to ask about.
How can I detect the number entered by the user in the txt file and display the name that i wanted to display?
For example:
User key in: 5
I should have displayed: Professor Hank Stalica
(Below are the data in the txt file)
[1] Titan
[2] Ryan
[3] Philip
[4] Sam
[5] Professor Hank Stalica
Hope to get your reply, and thank you Professor!
Thank you for your help :)
ОтветитьHey Hank! Australian uni student here, thanks heaps for the video mate, it really helped close some gaps in my knowledge. <3
ОтветитьLove You man! Your Whole Playlist on File handling is awesome!
Because of you I could complete my assignment.
Love From Pakistan.
You created the text file, but how did you make it so the program was able to access the text file? Sorry if it's a super basic question but I'm new to this. Is there a good video that explains what I'm asking (I can't find one).
Ответитьwhat if you are reading from a file with both words and numbers?
ОтветитьWhat should I do if I'm reading from a file that is a list of ints separated by commas? while(inFile >> x) only prints first int rn
ОтветитьVery helpful and i love the shirt too. A very educated man.
Ответитьwhat to do if you are trying to read strings that have spaces in them, ex: first and last names in one string
ОтветитьHI Professor Hank Stalica
I want to congratulate you on your work.
You are a great teacher. Good scientific knowledge and very good pedagog.
I really appreciate your video. Thank you very much.
Jorge Carvalho (Portugal)
PS: I like your shirt!
Hi professor,
Can u tell me where you got that shirt? I want 12 of it.
Thank you.
ugh.... sniffing.....
Ответитьhow can i read from class please
ОтветитьGreat tutorial so far, but I have a problem:
My file:
12 13 14 15 16
Code: (inside if statement)
int x
while (infile >> x)
{
cout << x << endl;
}
infile.close()
Output:
12
All my other code is identical to yours. I seem to have some problem with my while statement; no matter what I try, it only prints the first number in the file. Perhaps I am missing something. Would appreciate some help if possible.
awesome sir...
Ответить