J
jiing
[my bad code]
char ch ;
unsigned int temp_counter =0;
vector<int> buffer, buffer4;
vector<char> charBuffer;
while(! fin.eof() ){
fin.get( ch );
int temp;
(int(ch) < 0) ? (temp = int(ch)+256) : (temp = int(ch) );
buffer.push_back(temp);
charBuffer.push_back(ch);
}
//vector<char> to unsigned char*
char* buffer0;
buffer0 = & charBuffer; //????? here is a lot of questions
//unsigned char* to vector<int>
// I am not quite sure the following is right or not
for(unsigned int i = 0; i<charBuffer.size(); i++){
buffer4.push_back( ((int) *buffer0)+256 );
buffer0++;
}
[/my bad code]
I have two questions owing to poor knowledge of pointer
How to transform vector<char> to char*
and how to transform char* to vector<int>
Can any one teach me?
Thanks in advance.
-jiing-
char ch ;
unsigned int temp_counter =0;
vector<int> buffer, buffer4;
vector<char> charBuffer;
while(! fin.eof() ){
fin.get( ch );
int temp;
(int(ch) < 0) ? (temp = int(ch)+256) : (temp = int(ch) );
buffer.push_back(temp);
charBuffer.push_back(ch);
}
//vector<char> to unsigned char*
char* buffer0;
buffer0 = & charBuffer; //????? here is a lot of questions
//unsigned char* to vector<int>
// I am not quite sure the following is right or not
for(unsigned int i = 0; i<charBuffer.size(); i++){
buffer4.push_back( ((int) *buffer0)+256 );
buffer0++;
}
[/my bad code]
I have two questions owing to poor knowledge of pointer
How to transform vector<char> to char*
and how to transform char* to vector<int>
Can any one teach me?
Thanks in advance.
-jiing-