For all of you who are familiar with linux and what the "cat" command does. I have to write a similar version of this command in C but add a few extra features. For those of you who dont know what the cat command does, It lists the contents of a file. I have to write a function that will read in and list the contents of a file but I have to add in a feature that displays the the line number before the line. Although there is a problem with this. The file is listed correctly and the line numbers are correct but for some reason it appends another line number onto the end of the program. For Example :
Contents of File :
Test1
Test2
Test3
Output from the program
1 Test1
2 Test2
3 Test3
4
Im looking for suggestions on how I could solve this, Im not looking for code. I want to be able to do this myself just ideas on how I could solve it. Apparently its not a problem thats solved easily but Im looking for members of Neowin to give me some ideas. Thanks in Advance.
Question
+John Teacake MVC
For all of you who are familiar with linux and what the "cat" command does. I have to write a similar version of this command in C but add a few extra features. For those of you who dont know what the cat command does, It lists the contents of a file. I have to write a function that will read in and list the contents of a file but I have to add in a feature that displays the the line number before the line. Although there is a problem with this. The file is listed correctly and the line numbers are correct but for some reason it appends another line number onto the end of the program. For Example :
Contents of File :
Output from the programIm looking for suggestions on how I could solve this, Im not looking for code. I want to be able to do this myself just ideas on how I could solve it. Apparently its not a problem thats solved easily but Im looking for members of Neowin to give me some ideas. Thanks in Advance.
Edited by Sawyer12Link to comment
Share on other sites
11 answers to this question
Recommended Posts