Read A Specific Line From A File | C++ Example

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

I've been searching for fstream tutorial everywhere but its so difficult to understand everywhere. You made it easy to understand! Props to you!

Nixhekoo
Автор

Ive spent 6+ hours and all it took as a 6 min video to solve this. Thanks for the amazing video

natsue-bwzu
Автор

This worked perfectly! The way you explained everything in a step by step way was a huge help. One other thing I really need help with though is how to search a text file for a string? I have looked everywhere and tried using Getline() and the search function in a loop, similar to what you did here...but I can't get it to work. All I would need it to do is tell which line in a text file the string was found.

ctc
Автор

premium content as always! Many thanks!

leythecg
Автор

Nice video, would be nicer if you kept the code a bit more zoomed out to get the big picture. Especially towards the end. Cheers

kirikor
Автор

The file.eof() function does not work correctly for reading objects from a file as it copies one extra object. Does it not do the same for reading text data?

moodymonstrosity
Автор

my test.txt just wont open.. i alos tried giving the whole path, did not work :(

framo_official
Автор

How do I take a string (which is a substring of the file) as my user input which I want to search in the file and print out only the line containing that substring.

Example: In my menu.txt file there is a line "Pizza cost: $4"
In my program file I take a user input as "Pizza" and I want the entire line "Pizza cost: $4" to be displayed and not the other lines.

varadarajkamath
Автор

So the while loop reads the next line automatically if the current line is not same as line number and the end of file is not reached?

larenshboro
Автор

you could do while ( getline (file, line, '\n') ) { }

zainuldin
Автор

Hello Sir, i've been looking everywhere for an algorithm, to find a specific word in a string on lines , example "hello world, welcome to c++, tutorial", i want to search the file, let's say to find, "c++", i wrote a search function, to look inside array or vector, result same it's only finding, the first element "hello" and disregarding the other elements, any tutorial about that would be appreciate it, big thank you .

ManOwaRR
Автор

I need support. Location of the text file is: e:\tekst.txt . Program ask for the name of the file I want to read. Name of the file is written into string filename. Unfortunately I receive information " file failed to open ". How to give a path to the location of the file tekst.txt in the program line line -> plik.open(filename); ?

pawemarkowski