I am not sure I understand what you want. Maybe, the following code can help you. I write it using C++, you can translate it to C. This code can replace the text Set wallpaper="aaaa" with Set wallpaper="text"
int main(int argc, char *argv[])
{
string text = "text";
string str;
vector<string> fileContent;
ifstream infile("hello.txt");
//infile.getline(str);
while ( getline(infile, str) )
{
cout<<str<<endl;
if ( str.find("Set wallpaper=") != string::npos )
{
str = "Set wallpaper=\"";
str += text;
str += "\"";
}
fileContent.push_back(str);
}
infile.close();
ofstream outfile("hello.txt");
for (int i=0; i<fileContent.size(); ++i)
{
outfile<<fileContent[i]<<endl;
}
outfile.close();
system("PAUSE");
return EXIT_SUCCESS;
}