TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: All
from: Daryl Willis
date: 1996-04-04 10:59:04
subject: help

Hi all, Can anyone spot any problems with this code?
It is just a snip of the original;
It is a Directory lister, I get The files, attrib, size into
a structure, I can print it all with no problems, however
when I pass the structure through this sorting routine
I end up with a Null Pointer asignment. What sort of tests can
I perform to eradicate the bug?. If I only pass the Files through
(see Below) it works fine but when I pass anything else through
ie: attribs and/or size of ,
I end up with a Null Pointer assignment  !!!!

<------- sniped
void SortTheFiles()
{
char *tempattrib;
long int size;
char *tempfile;             // temp storage for the swap
int Num_files = files-1 ;   // Number of Files and Directories -1
int stat,i,loopcount,a;
for (loopcount = 0;loopcount < Num_files; loopcount++)
        {
                for(i = loopcount; i <= Num_files; i++)
                {
stat = memicmp(Filesfound[loopcount].Files,Filesfound[i].Files,2);
if (stat > 0)
{
/*Files*/
                                        strcpy(tempfile,Filesfound[loopcount].Files);
strcpy(Filesfound[loopcount].Files,Filesfound[i].Files);
strcpy(Filesfound[i].Files,tempfile);
                                        /* Attribs*/
                                       
strcpy(tempattrib,Filesfound[loopcount].attribf);
strcpy(Filesfound[loopcount].attribf,Filesfound[i].attribf);
strcpy(Filesfound[i].attribf,tempattrib);
                                        /*File Size*/
size = Filesfound[loopcount].Fsize;
Filesfound[loopcount].Fsize = Filesfound[i].Fsize;
Filesfound[i].Fsize = size;
                                 }
 }
}
}
<------Sniped



--- TMail v1.31.5


* Origin: MultiLine 140+ CDRoms 50+Lines Internet +619 370-3333 (3:690/254)
SEEN-BY: 50/99 78/0 620/243 623/630 640/820 690/115 245 254 354 370 416 500
SEEN-BY: 690/660 676 711/401 409 410 413 430 808 809 932 934 712/515 713/888
SEEN-BY: 714/906 800/1 7877/2809
@PATH: 690/254 660 711/409 808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.