Value of Char[]
Feb 14, 2011 at 3:56pm UTC
Hi Everyone,
i am currently using this code to loop through the possible HWID's:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void checkHWID(char buf[])
{
int result;
char HWID00[33] = "3030FBC17070D6DA250C0B28880FF1BE" ;
char HWID01[33] = "5C030FBC1740D6DA250C0B42880FF1BE" ;
char HWID02[33] = "BAA982909C868C657003547527338892" ;
char curHWID[7];
for (int i = 0; i < 3; i++)
{
sprintf(curHWID,"HWID%02d" ,i);
result = strcmp(buf,curHWID);
}
}
this correctly loops from HWID00 till HWID02.
but the problem is , it compares buf with "HWID02" but i want it to compare
buf and the value of HWID02.
can anyone help me on this ?
thanks in advance.
Feb 14, 2011 at 4:54pm UTC
Let me guess... ex script language programmer? This doesn't work in C++ (or any other compiled language for that matter). You'd have to put the strings into an array and iterate over the array.
Feb 14, 2011 at 4:54pm UTC
There isn't a way to do it like that. You can't build variable names out of strings like that. But you can do:
1 2 3 4 5 6 7 8 9 10 11 12
void checkHWID(char buf[])
{
int result;
char hwids[][33] = {
"3030FBC17070D6DA250C0B28880FF1BE" ,
"5C030FBC1740D6DA250C0B42880FF1BE" ,
"BAA982909C868C657003547527338892"
};
for (int i = 0; i < 3; i++)
result = strcmp(buf,hwids[i]);
}
Feb 14, 2011 at 10:24pm UTC
thanks for the help everyone ! now i get it :)
xD used to programming another way lol
thanks !
Topic archived. No new replies allowed.