haha didn't know about the compiler helping people out haha
yah...but all langauges .net java are just proxys!! i dont like that **** i want native complication real assembly not bytecode
Printable View
haha didn't know about the compiler helping people out haha
yah...but all langauges .net java are just proxys!! i dont like that **** i want native complication real assembly not bytecode
If you want to use an array where you can specify the size of it at runtime, you can either use pointers and dynamically allocated memory, or use std::vector.Quote:
Originally Posted by Fuji22
The same code using vector:Code:char temp[(res/2)+sizeof(char)] = {0}; //allocate temp array <- the hell this giving me a array for error C2466: cannot allocate an array of constant size 0
Then you use temp just like an array. Note there is no need for pointers, however there is a need to know what C++ facilities allow you to declare dynamic arrays without pointers, and vector (and for MFC, vector or CArray) are the ones that does this.Code:#include <vector>
//...
std::vector<char> temp((res/2)+sizeof(char), 0);
Also, realize that strtok() mangles the string you send to it, so your strData is not the same after you call strtok(). For example,Code:char *p = strtok(strData, " "); //split hex characters by space
int curPos = 0;
while(p != NULL) //if pointer is not NULL
{
temp[curPos]=(char)strtoul(p, NULL, 0x10);
p = strtok(NULL, " ");
curPos++;
}
This line in your program is highly suspicious.Code:char* temp=strdup(strData);
Regards,
Paul McKenzie
You dont, but I thought I would try to keep the syntax similar for you.Quote:
Originally Posted by Fuji22
I like Java too, but C is a nice chizzle in the toolbox.Quote:
Originally Posted by Fuji22
Well a pointer is just a variable that allows you to access the memory address it contains. It is pretty light.Quote:
Originally Posted by Fuji22
You can depending on the types you use.Quote:
Originally Posted by Fuji22
I thought that was Java. :)Quote:
Originally Posted by Fuji22
Might as well just learn to use your tools. You can get all the functionality out of them that you wish, although you will have to get out a book or two. Of course you could just do what Paul suggested.....although you should probably get a good C++ book.