473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Bit operations on buffers

PSN
Hello Group,
I have a character array of size 2;

char *pArray=(char *)malloc(10);
memset(pArray, 1, 10); // 0000000100000001

I want to apply shift operations, so as '&' and '|' operations on the
whole buffer at once. How can i do it ??

Ex: pArray & 0x01 ----1;
pArray >1 ----0000000010000000;

The 2 character buffer is just an example, and i wish to use buffers
of variable sizes.

Thanks a lot again for your time,

Prakash

Dec 16 '07 #1
3 1264
PSN wrote:
Hello Group,
I have a character array of size 2;

char *pArray=(char *)malloc(10);
Why are you using malloc?
memset(pArray, 1, 10); // 0000000100000001

I want to apply shift operations, so as '&' and '|' operations on the
whole buffer at once. How can i do it ??

Ex: pArray & 0x01 ----1;
pArray >1 ----0000000010000000;

The 2 character buffer is just an example, and i wish to use buffers
of variable sizes.
Have a look at std::bitset.

--
Ian Collins.
Dec 16 '07 #2
PSN
I am aware of the bitset container.
Have a look at std::bitset.
Can i dare to say, i want to reinvent the wheel and wish to know
exactly what i am doing behind the covers !!
>
--
Ian Collins.
thanks for your time again,
Prakash
Dec 16 '07 #3
PSN wrote:
I am aware of the bitset container.
>Have a look at std::bitset.

Can i dare to say, i want to reinvent the wheel and wish to know
exactly what i am doing behind the covers !!
In that case, rolling your own should prove an interesting exercise!

--
Ian Collins.
Dec 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: doodle4 | last post by:
Hello, I need to create 6 buffers in python and keep track of it. I need to pass this buffer, say buffer 1 as an index to a test app. Has any one tried to do this. Any help with buffer...
13
by: Steve | last post by:
Can someone write a sample c code showing how one can find an instance of a word or a char in a file (including opening and closing a file)? Thanks
18
by: JG | last post by:
Does anyone know a standard (or supported on Linux, Mac, Win32) way to clear a read stream buffer (standard ANSI C file stream)? I would even settle for a platform specific way of doing it. ...
2
by: ldawson | last post by:
From the same C++ source code, I'm attempting to generate both an unmanaged DLL and a managed assembly. This will eliminate interop as the calling code is slowly migrated to .NET. However, C++...
3
by: yuvalif | last post by:
I want to get rid of my "sprintf" call, so I wrote the following example, in which I have two problems: (1) why do I need to inherit from "streambuf", and not just use it as a local in my "ToBuff"...
3
by: Sally Sally | last post by:
I have a very basic question on the two parameters shared buffers and effective cache size. I have read articles on what each is about etc. But I still think I don't quite grasp what these settings...
2
by: | last post by:
Hi, we are planning to rewrite an extisting C++ image processing application/library in C#. Now several question arouse where I hope you can help me: So far we allocated a block of memory as...
2
by: Alex Vinokur | last post by:
I need a container of char-buffers, for instance, vector of char-buffers. vector<string> v; // It is not what I need to char a; memset (&a, 0, sizeof (a)); v.push_back(a);
2
by: chenxinleo | last post by:
Hi, When i use some standard library functions and fields,which return char* type(like ctime in time.h, optarg in getopt.h)and do not have to be freed after calling,i always worry about memory...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.