Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ find char in vector of unsigned chars

I have the problem with the following code:

message is vector<unsigned char>

vector<unsigned char>::iterator pos = message.begin();
vector<unsigned char>::iterator start = message.begin();
vector<unsigned char>::iterator end = message.end();

pos = find(start, end, ' ');

I got the error:

error: no matching function for call to ‘find(std::vector<unsigned char>::iterator&, std::vector<unsigned char>::iterator&, char)’
like image 372
M.K. Avatar asked Jun 26 '11 16:06

M.K.


People also ask

How do I find a character in a vector?

C++ vector does not have a find member function. However, the algorithm library has a find() function of different types that can be used to find something in a C++ vector. The algorithm library has four groups of find() functions that can be classified as Find, Find End, Find First, and Adjacent Find.

Is there unsigned char in C?

unsigned char is a character datatype where the variable consumes all the 8 bits of the memory and there is no sign bit (which is there in signed char). So it means that the range of unsigned char data type ranges from 0 to 255.

How to define unsigned char?

unsigned char ch = 'n'; Both of the Signed and Unsigned char, they are of 8-bits. So for signed char it can store value from -128 to +127, and the unsigned char will store 0 to 255.

What is unsigned char pointer in C?

In C, unsigned char is the only type guaranteed to have no trapping values, and which guarantees copying will result in an exact bitwise image. (C++ extends this guarantee to char as well.) For this reason, it is traditionally used for "raw memory" (e.g. the semantics of memcpy are defined in terms of unsigned char ).


1 Answers

Are you including <algorithm>?

like image 88
Peter Alexander Avatar answered Sep 22 '22 01:09

Peter Alexander