سلام
چجوری میشه []char رو به int تبدیل کرد؟
:rolleyes:
لطفا راهنماییم کنین
چجوری میشه []char رو به int تبدیل کرد؟
:rolleyes:لطفا راهنماییم کنین

fgets(str,7,f);
tftlcd_write_pixel(0,0,str);


fgets(str,7,f);
tftlcd_write_pixel(0,0,str);
tftlcd_write_pixel(0,0, (int)str[0]);
str[0]=0x001f;
a=str[0];
#include<iostream>
using namespace std;
char s[]="000126A0\0";
unsigned long int tabdil(char* a){
unsigned long int b=0;
while(*a != '\0'){
if (*a < 65){
b*=16; // Base is 16. Digit shifting.
b+= ((unsigned long int) *a) - 48; // '0' = 48 --> Ascii value of char variable.
}
else {
b*=16; // Base is 16. Digit shifting.
b+= ((unsigned long int) *a) - 55; // Ascii value of character 'A' = 65 But A represents 10 (A = 10) in hexadecimal --> 65 - 10 = 55
}
a++;
}
return b;
}
int main(){
unsigned long int x;
x=tabdil(&s[0]);
cout<<x<<'\n';
return 0;
}
دیدگاه