We are having a file.
In a file content is.
file.txt
Voltage 1000
current 100
power 600
amplitude 10
We have opened the file in r+ mode and trying to change the data in 3rd line power 1000 in a file but its is not changing we are using this logic can any one help me out finding in solution.
I cann't use fseek because in a line content may vary.
[C]code[\C]
while(count < line)
{
fscanf(fptest,"%s %d",temp,&value);
cout<<temp<<value<<endl;
count++;
if(count == line)
{
//fptest = fopen("UserConfigWrite.ini","r+");
//strcpy(temp,temp1);
value = 200;
fprintf(fptest,"%d\n",value);
cout<<temp<<value<<endl;
fclose(fptest);
break;
}
//fclose(fptest);
}
[C]code[\C]
In a file content is.
file.txt
Voltage 1000
current 100
power 600
amplitude 10
We have opened the file in r+ mode and trying to change the data in 3rd line power 1000 in a file but its is not changing we are using this logic can any one help me out finding in solution.
I cann't use fseek because in a line content may vary.
[C]code[\C]
while(count < line)
{
fscanf(fptest,"%s %d",temp,&value);
cout<<temp<<value<<endl;
count++;
if(count == line)
{
//fptest = fopen("UserConfigWrite.ini","r+");
//strcpy(temp,temp1);
value = 200;
fprintf(fptest,"%d\n",value);
cout<<temp<<value<<endl;
fclose(fptest);
break;
}
//fclose(fptest);
}
[C]code[\C]