Code: Select all
char *Trim(char *Tstr) {
unsigned short int a=0,i=0;
char *temp;
while(Tstr[a] == 0x20) {
a++;
};
while (Tstr[a]!=0){
temp[i]=Tstr[a];
i++;
a++;
};
temp[i]=0;
return temp;
}
#1 Post by Aoday » 17 May 2005 07:05
Code: Select all
char *Trim(char *Tstr) {
unsigned short int a=0,i=0;
char *temp;
while(Tstr[a] == 0x20) {
a++;
};
while (Tstr[a]!=0){
temp[i]=Tstr[a];
i++;
a++;
};
temp[i]=0;
return temp;
}
#2 Post by rajkovic » 17 May 2005 08:13
Aoday wrote:when I used bytetostr function I found that the number converted and there a space before the number i.e if I want to convert number 5 it became " 5" if 55 became " 55" 255 became "255" you can see there is a space leads the number so I tried to make trim function to delete this spaces there is something error the function some time work and some times not working:please some one help meCode: Select all
char *Trim(char *Tstr) { unsigned short int a=0,i=0; char *temp; while(Tstr[a] == 0x20) { a++; }; while (Tstr[a]!=0){ temp[i]=Tstr[a]; i++; a++; }; temp[i]=0; return temp; }
Code: Select all
temp[i]=Tstr[a];
Code: Select all
char* Trim(char *Tstr) {
unsigned short int a=0,i=0;
while(Tstr[a] == 0x20) {
a++;
};
while (Tstr[a]!=0){
Tstr[i]=Tstr[a];
i++;
a++;
};
Tstr[i] = 0;
return Tstr;
}
char Str[10];
void main(){
byteToStr(5,Str);
Trim(str);
}
#3 Post by gambrose » 18 May 2005 17:00
Code: Select all
char * Trim(char *toTrim)
{
while(*toTrim == 0x20)
{
toTrim++;
}
return toTrim;
}