Compiler - Turbo c++ v4.5 (Borland)
OS - Win Me/98
Well i have created a program to write to a.txt file
here's the part of the codes:
Code:
add()
{
int x;
ptr=fopen("data.txt","a+");
for(x=0;x<2;x++)
{
printf("\nID: ");
scanf("%d",&field[x].id);
printf("\nName: ");
scanf(" %[^\n]",field[x].name);
printf("\nQty: ") ;
scanf("%d",&field[x].qty);
printf("\nPrice: ") ;
scanf(" %lf",&field[x].price);
fprintf(ptr, "%d|", field[x].id);
fprintf(ptr, "%s|", field[x].name);
fprintf(ptr, "%d|", field[x].qty);
fprintf(ptr, "%.2lf\n", field[x].price);
}
fclose(ptr);
return 0;
}
File contents stored like below
ID|toyname|qty|price
Ex.:
001|mickey mouse|12|25.00
002|donald duck|21|23.10
003|abc,..|17|5.00
1) How do i read line by line and display it on the screen without the "|"?
Ex. ID : 001
Toy: mickey mouse
Qty: 12
Price : 25.00
ID : 002
Toy: donald duck
Qty: 21
Price : 23.10
Please provide me a simple program code which can read the data..