Ow can I insert or delete a line (or record) in the middle of a file?



Ow can I insert or delete a line (or record) in the middle of a file?..

Answer / Manas Mishra

To insert a line in the middle of a file, you typically don't overwrite the existing file. Instead, you write the new content to a temporary file and then rename it to replace the original file. For deleting a line, you would read the file into memory, remove the desired line, and then write the modified data back to the file.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What is the difference between printf and scanf )?

1 Answers  


Which programming language is best for getting job 2020?

1 Answers  


Can you define which header file to include at compile time?

1 Answers   Aspire, Infogain,


What is meant by 'bit masking'?

1 Answers  


5. distance conversion: Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer

4 Answers  


Why can’t we compare structures?

1 Answers  


#include<stdio.h> { printf("Hello"); } how compile time affects when we add additional header file <conio.h>.

1 Answers  


Predict the output or error(s) for the following: 25. main() { printf("%p",main); }

3 Answers   Google, ME,


write a c program to remove all the duplicate characters in a string and replace with single character? ex:-input- AAABBBCCC output- ABC

2 Answers   HCL,


Would you rather wait for the results of a quicksort, a linear search, or a bubble sort on a 200000 element array? 1) Quicksort 2) Linear Search 3) Bubble Sort

3 Answers  


Explain the use of function toupper() with and example code?

1 Answers  


Explain the difference between exit() and _exit() function?

1 Answers  


Categories