我目前正在尝试在 C 中编辑 .txt 文件的特定行。我使用的文件如下所示:
现在假设我想更改图像上突出显示的特定行上所写的内容:
400,300:(255,255,255)#FFFFFF
进入这个:
400,300: (000,000,000) #000000
基本上,我试图在特定像素上创建一个黑点,在本例中是 400,300。这就是我的代码:
#include <stdio.h>
int main(void)
{
const char *filename = "sample.txt";
int x = 400;
int y = 300;
FILE *fp;
fp = fopen(filename, "w+");
// Algorithm that reads all the file
// If("Operation that reads" == x+","+y)
// {
// Replace the line information after where it starts with "400,300"
// Like this : 400,300: (000,000,000) #000000
// }
// Algorithm that saves the …Run Code Online (Sandbox Code Playgroud)