I want to go to to specific line no of a new text file and write some data on that line number. Like for example my data is 23 51 62
i want line 3 to have 23 line 1 to have 51 line 2 to have 62 and so on How do i jump to different line number for every data
void main()
{
int i=0;
FILE *fconfig;
fconfig = fopen("config_new.txt","w");
for ( i = 0; i < 5; i++)
{
/* code */
if(fconfig == NULL)
{
printf("error!\n");
exit(1);
}
// scanf("%d",&num);
if(i%2 == 0)
{
fseek(fconfig,0+i,0);
fprintf(fconfig, "%d\n", i+17 );
}
}
// fclose(fconfig);
}
i want txt file to have data on even line numbers and \n on others.
This doesen't seem to work. What am i missing here.