Originally Posted by
mammoth
Here's the output of what gets stored (with the top row as normal):
Code:
# Num Description Type Qty Price Cost Profit
========================================================================
1 0002 Tacos 2 4 8.00 7.00 4.00
2-858993460 ╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠xöS,ä■↕-858993460-858993460-9255963134931783100000000000000000000
0000000000000000000000000.00-925596313493178310000000000000000000000000000000000
00000000000.00 -0.00
Any idea why that is happening?
Yep... you didn't clear the struct before creating the data...
When adding a new record you should always use mset(&struct,0,sizeof(struct)); before adding data to it.
Code:
mset(&recs,0,sizeof(recs));
recs.prodtype = 0;
fseek(bf, spot, SEEK_SET);
fwrite(&recs, sizeof(recs), 1, bf);
}
Also the seek and write functions should be inside your conditional to prevent it from writing garbage if the operator enters an invalid record number.
When editing (eg. changing pricess and such...) you will still get some interspersed garbage if you shorten a string, but numbers are fixed size and should stay clean... for example if you replace "Taco Bell Tacos" with "Hot Dogs"... the record in raw view will show... "Hot Dogs l Tacos" ... this is of no consequence as long as your strings are properly null terminated.
Plus... if a record is deleted, you should not display it at all... maybe just the searched number and "<-deleted->" at most