fat pading

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
GLneo

fat pading

Post by GLneo »

hi all, for any one who doesn't know for fat names, you must convert names as follows:

Code: Select all

"file.txt" -> "file    txt"
so that before the dot has 8 places aftor 3.

my code simply copys letter per letter, if a dot what ever is left is "spaced":

Code: Select all

unsigned char *fat_pad(unsigned char *str)
{
    int pc = 0, sc = 0; // pc = paded count, sc = str count
    while(str[sc] != '\0') // while more left in string
    {
        if(str[sc] == '.') // if dot
        {
            for(; pc < 8; pc++) // untill 8
                paded[pc] = ' '; // space pad
            sc++; // jump over dot
        }    
        paded[pc] = str[sc]; // reg letter just transfer
        pc++; sc++; // move 1 letter ahead
    }
    return paded; // return new string
}
when i run it, it kills the system???
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:fat pading

Post by distantvoices »

hm. where do you declare "paded" - that array you copy the passed string to? and where do you acquire the memory needed for "paded"

I daresay that's the first problem I see at a short glance. Fix it, give it a try once more.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
GLneo

Re:fat pading

Post by GLneo »

paded is a globle variable so i dont pass internal variable

EDIT: nevermine you were right, thx
Post Reply