0
votes

I have used fgets as well as fscanf to read a file line by line but all the time I have got some wrong output.

1st line of the file contain 149 characters and 2nd line contains 122 characters, but in my output file it shows 1st line contain 149 but 2nd line contain 128.

1
Show us the code you're using, and the input and output, and why it is not what you expect. Try to reduce it to a smaller program that shows the problem with less input, if you can. - detly
Please update your post to include the code that reads from file 1 and writes to file 2. Without that, we're just guessing and hinting at common mistakes. - Tim Post
in C that extra 6 chars are normal, it just tells that you did not truncate the data with \n and you are getting garbage chars. - balexandre

1 Answers

0
votes

By output file do you mean to say that you are reading from one file and writing it into another? Are you manipulating the string before writing it? If that is the case then maybe your manipulaion is repositioning the newline characther. Just a guess. We will need to see the code.