Write a program that reads and prints a joke and its punch line from two different files. The first file contains a joke, but not its punch line. The second file has the punch line as its last line, preceded by “garbage.” The main function of your program should open the two files and then call two functions, passing each one the file it needs. The first function should read and display each line in the file it is passed (the joke file). The second function should display only the last line of the file it is passed (the punch line file). It should find this line by seeking to the end of the file and then backing up to the beginning of the last line. Data to test your program can be found in the joke.txt and punchline.txt files.
Hello Seniors, I have mentioned problem of my code, kindly guide me.
My first part of the program (function "Jokedata") works well. but I have problem in 2nd part of the program (function "Punchlinedata"). It doesn't show last line of the file. Code is given below...
Dear Zapshe, Actually Joke is another file that is running accurately. Punchline is another file that is running separately and I want to get last line of that file. I got your point for mentioning the while(std::getline(file, str)).
Thankyou so much.