ANSI C - Text File: Modify Line?
问题 I have this text file: Line 1. "house" Line 2. "dog" Line 3. "mouse" Line 4. "car" ... I want to change Line 2. "dog" in new Line 2."cards" how can I do? thanks! (sorry for my bad English) 回答1: Your program could like this: #include <stdio.h> #include <stdlib.h> #define MAX_LINE_LENGTH 1000 int main() { FILE * fp_src, *fp_dest; char line[MAX_LINE_LENGTH]; fp_src = fopen("PATH_TO_FILE\\test.txt", "r"); // This is the file to change if (fp_src == NULL) exit(EXIT_FAILURE); fp_dest = fopen("PATH