
Help Please : Weird things happening with printing text in graphics mode using Turbo C++
: Hi, please help.
: Ive added a phone book to an MSDos invoicing program. It gives name and
: number only.
: When you first start the program and go the the phone book, it works fine.
: But when you go to another section of the program, and then leave that to go
: to the phone book, some of the information is missing. Below is an
: excerpt...
: outtextxy(listwin.p[0].x+15,listwin.p[0].y+y,refnum); //
: prints fine
: outtextxy(listwin.p[0].x+60,listwin.p[0].y+y,name); // does
: not appear!
: outtextxy(listwin.p[0].x+360,listwin.p[0].y+y,number); // prints
: fine
: (Ignore the coordinate references).
: It prints the refnum and the number, but not the name!
: Also, headings (ie "Ref" , " Name" , and "Number" suddenly disappear!
: The total program size is quite large (240K), so could it be down to a lack
: of core memory at the time of printing causing a font to not be loaded? But
: it doesn't work whatever font I use, and a call to coreleft() informs me I
: still have lots of core remaining!, and why print the first and last parts
: of the line, and not the middle?
At a guess, somewhere you're leaking or overwriting memory. If your
compiler doesn't have tools to check memory usage, then you'll have
to trim the program down until you've localised the fault. There's
not much that can be discovered from the lines you've posted: the
problem was almost certainly set up elsewhere in the code, and those
lines are just the trigger.
: Please help, as Im going bald pulling my hair out!
: The above excerpt is as it stands, with no font/charsize/etc changes being
: made between the outtextxy() calls.
: And, if i may be a pain, I need to sort a list of customers names into
: alphabetical order. I have a book, (Practical C++ Programming, Steve
: Oualline, Reilly & Assoc) that shows me how to do it using binary trees, but
: this is in C++. I am a bit unsure about referencing, so is there anyway a
: binary tree can be implemented in C without using reference pointers?
If you want to sort in C++, the STL is probably the place to start.
You'll have to ask in comp.lang.c++ for more information. In C, you
probably want to start with qsort(), which is part of the library.
You can implement a (form of) binary tree in an array, without pointers,
by storing the children of node a[n] in a[2n] and a[2n+1]. If you do
this, you can implement a neat and fairly quick form of heapsort without
more than one node's worth of extra space. Most books on algorithms
discuss heap sorts.
Will