Questions tagged [unsigned-char]
321 questions
2
votes
1 answer
What is the template argument when reading a binary file to "unsigned char" vector
What's wrong with this code?
std::vector newVector;
std::ifstream inFile(fullPath.c_str(), std::ios::in|std::ios::binary);
std::istreambuf_iterator iterator(inFile);
It gives me this:
missing template arguments before…

Mikael S.
- 1,005
- 3
- 14
- 28
2
votes
1 answer
C++ - Allocate an unsigned char buffer and then fill it with a string
I am realively new to C++ so please forgive me if this is a naive question - but I'm stuck on finding an answer.
I am trying to create an unsigned char array of size 1024 which I have done with the following code:
unsigned char *r_record = new…

Brett
- 11,637
- 34
- 127
- 213
2
votes
3 answers
Reading binary data with fstream method
I need to read binary data to buffer, but in the fstreams I have read function reading data into char buffer, so my question is:
How to transport/cast binary data into unsigned char buffer and is it best solution in this case?
Example
char…

CppMonster
- 1,216
- 4
- 18
- 35
2
votes
2 answers
Is NULL (or 0 or '\0') value interpreted differently in unsigned char array and char array in c++?
How is NULL (or 0 or '\0') behaved in unsigned char array and char array? In a char array NULL determines the end of the char array. Is it the same case with an unsigned char array? If not how can we determine the end of an unsigned char array?

annunarcist
- 1,637
- 3
- 20
- 42
2
votes
4 answers
Some Simple C++ Questions
I don't know much about C++ (almost nothing), meaning I'm a noob at C++.
1.
Let's say you have this code:
typedef unsigned char u8;
With this code, does it mean that when you create a variable you can write u8 instead of unsigned char? Is an…

user2746752
- 1,028
- 1
- 13
- 25
2
votes
3 answers
How to convert a double into an unsigned char?
I'm looking to change a vector of doubles into unsigned chars using c++.
To make sure it works I wrote:
unsigned char x = 0;
double y = 4.6;
x = (unsigned char) y;
printf("%d", y);
cout << endl << "the char of 4.6 is: " << x;
getchar();
but instead…
user2719805
2
votes
1 answer
Packet sniffer only detects sent packets
I have been working on a packet sniffer just for fun/education and it's been going quite well. The problem that I'm having is that the only packets appearing in recvfrom() are SENT packets i.e. packets with my IP as their source IP and not my WAN IP…

Robert
- 119
- 8
2
votes
2 answers
Arduino converting between uint32_t and unsigned chars
I'm using the rainbowduino and it has some methods that take individual r g b values as unsigned chars, and some that take a 24bit rgb colour code.
I want to convert r g b values into this 24bit colour code of type uint32_t (so that all my code only…

holmeswatson
- 969
- 3
- 14
- 39
2
votes
3 answers
Count characters in UTF8 when plain char is unsigned
In UTF8 I use to count characters (not bytes) using this function:
int schars(const char *s)
{
int i = 0;
while (*s) {
if ((*s & 0xc0) != 0x80) i++;
s++;
}
return i;
}
Does this work on implementations where plain…

David Ranieri
- 39,972
- 7
- 52
- 94
2
votes
2 answers
unsigned char ** equivalent in c# and have to write the return value in a file
I have to call a win32 dll function
int func1( int arg1, unsigned char **arg2, int *arg3);
and i need wrapped in c# as
public extern int fuc1(int arg1, out IntPtr arg2, out IntPtr arg3);
and i called it from a c# application as
int arg1;
IntPtr…

Narayan
- 1,189
- 6
- 15
- 33
2
votes
1 answer
Minimally invasive change for strchr on unsigned char * in C++ from a C codebase?
I'm trying to compile a C codebase as C++, tweaking some of the includes. It uses strchr() on unsigned char pointers, e.g.:
#include
#include
// Cannot modify this file with any non-C-isms, but let's say an include can
// be…

HostileFork says dont trust SE
- 32,904
- 11
- 98
- 167
2
votes
1 answer
using unsigned char and string as function declarations
I am required to write a function called bitstring, which takes a unsigned char that was created in this function:
size_t bs2n(string s)
{
assert (s.size() > 0);
if (s.size() == 1)
return s[0]-'0';
else {
string smaller =…

Kurt E
- 367
- 1
- 2
- 9
2
votes
1 answer
How to define swig typemap for returning unsigned char* back to java
I have a Java Application that calls a c library for performing crypto functions.
This is a custom library implemented in c that we need to use from some Java programs.
I need a way to define a SWIG typemap that will allow me call a function passing…

Yogesh Devi
- 617
- 11
- 30
2
votes
2 answers
unsigned char alloc and free issue
I'm confused about one strange thing....I have an unsigned char array.... I allocate it using calloc and record some bytes data in it... but when I free this unsigned char and allocate it again, I see that it reserves the same address in memory…

Garnik
- 423
- 1
- 6
- 20
2
votes
3 answers
c++ how to convert my command line argument (MAC Address) to unsigned char
I have a program and I want to take a command line argument of a MAC address like "./myapp 00:11:22:33:44:55"
Later on the MAC address is used for struct sockaddr_ll.sll_addr in an unsigned char array, each element is one octet of the MAC address.…

jwbensley
- 10,534
- 19
- 75
- 93