473,410 Members | 1,907 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,410 software developers and data experts.

A Little help with Bits...

help me with this problem. I have stated this:

typedef unsigned short WORD;
struct cube {
WORD t;
WORD f;
};
typedef struct cube CUBE;
CUBE cubes[MAX_VARS+1][MAX_CUBES];

And i have to make a procedure that will read from the keyboard
binaries and activate the .t or .f of cubes array accordingly.
Will activate 1 in .t if if we have 1 in that place, 1 in .f if we have
0 in that place and 0 in both places if that place has a '-'.

EXAMPLE:
IF I INSERT P= 1010001 WILL MAKE:
cubes[0][j].t = (1010001)
cubes[0][j].f = (0101110)

If i put P = 101-001 will make:
cubes[0][j].t = (1010001)
cubes[0][j].f = (0100110)

Please some help would be REALLY appreciated. You can contact me at:

p3tris (at) gmail (dot) com

May 7 '06 #1
3 1466
posted:
help me with this problem. I have stated this:

typedef unsigned short WORD;
struct cube {
WORD t;
WORD f;
};
typedef struct cube CUBE;
CUBE cubes[MAX_VARS+1][MAX_CUBES];

Cubes have three dimensions.

And i have to make a procedure that will read from the keyboard
binaries and activate the .t or .f of cubes array accordingly.
Will activate 1 in .t if if we have 1 in that place, 1 in .f if we have
0 in that place and 0 in both places if that place has a '-'.

Very poorly worded -- I don't know what you're saying.

What do you mean by "read binaries from the keyboard"? What do you mean by
"activate the .t or .f"?

EXAMPLE:
IF I INSERT P= 1010001 WILL MAKE:
cubes[0][j].t = (1010001)
cubes[0][j].f = (0101110)

If i put P = 101-001 will make:
cubes[0][j].t = (1010001)
cubes[0][j].f = (0100110)

Please some help would be REALLY appreciated. You can contact me at:

p3tris (at) gmail (dot) com

Is that the billing address?
-Tomás
May 7 '06 #2
<p3****@gmail.com> wrote:
typedef unsigned short WORD;
struct cube {
WORD t;
WORD f;
};
typedef struct cube CUBE;
CUBE cubes[MAX_VARS+1][MAX_CUBES];

And i have to make a procedure that will read from the keyboard
binaries and activate the .t or .f of cubes array accordingly.
Will activate 1 in .t if if we have 1 in that place, 1 in .f if we have
0 in that place and 0 in both places if that place has a '-'.

EXAMPLE:
IF I INSERT P= 1010001 WILL MAKE:
cubes[0][j].t = (1010001)
cubes[0][j].f = (0101110)

If i put P = 101-001 will make:
cubes[0][j].t = (1010001)
cubes[0][j].f = (0100110)


You have embedded a fairly simple problem in a lot of non-issues. Including
a two-dimensional array that has nothing to do with your apparent problem.
I think the word you want for "activate" is "set". In C, the word for
procedure is function. You can not read binary from a keyboard, what you
can do is read characters and convert the characters into binary. Defer the
'-' problem at first, if there is a hyphen in the input, replace it with a
"don't care", either 1 or 0. Having done that (and ignoring the seven bit
situation), if k contains the binary input, then,

char a, b;

a = k does the .t thing
b = ~k. does the .f thing. (~ is one's complement)

Then handle the hyphen. You can force a 0 by selective use of the &
operator, note that 1 & 0 = 0 and 0 & 0 is also 0. So the right bit is
often called a "mask".

The word cube seems like an improbable name for a thing with only two
constituent elements.

I suggest you get these basics working and then and only then incorporating
what you have into an array.
May 7 '06 #3
In article <11**********************@e56g2000cwe.googlegroups .com>,
<p3****@gmail.com> wrote:
And i have to make a procedure that will read from the keyboard
binaries and activate the .t or .f of cubes array accordingly.
Will activate 1 in .t if if we have 1 in that place, 1 in .f if we have
0 in that place and 0 in both places if that place has a '-'.


When you say "binaries", do you mean "The text representation of
a binary string" ?

Your input strings are not binary, by the way: they are trinary,
since each position can have 3 states.
--
Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us. -- Ecclesiastes
May 7 '06 #4

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

Similar topics

16
by: Henri Schomäcker | last post by:
Hi folks, I am developing a apache2 so module in c++. At the moment, I'm trying to get it to compile with automake & friends, but don't get it to work. I tried to modify the example in the...
1
by: cedar chak | last post by:
ascii decimal binary 0 48 00110000 1 49 00110001 .... ... ... 9 57 00111001 My problem is: when i get a serial numbers,i wanna to remove 00 from left of each binary value and save them as...
2
by: VanBurg | last post by:
Hallo! I have to do the following tasks: 1) I need to read first 4 bytes from file 2) Get all 32 bits for editing 3) Change some bits and save its back to file For now i have to understand...
1
by: SSPoke | last post by:
Hello I attempted to make one in VB.NET but it dind't work at all.. Private buffer() As Byte 'OUTPUT OF BITS goes here Dim bitPosition as Integer = Buffer(i) * 8 'current position of Buffer...
2
by: Gus007 | last post by:
Hi all, I am new in this community but already need support as below: Hope you guys could help! The idea was: The user input some text in the program and then I put the information inserted in...
7
by: =?Utf-8?B?U3VzaGlTZWFu?= | last post by:
I have some problems which getting bites. For example 247 it is 11110111 in bytes. int i = 247; // 11110111 How I can get some pozition on bite? Something like this i = 1; i = 1; i = 1;
2
by: skalig1 | last post by:
Hey the title was just to attract people to my problem.......well my problem is .... i code in vc++ and i have a situation which is like this....... i have a buffer which holds data in the...
2
by: s gall | last post by:
Hi all I have a task to test a checksum algrorithum. This requires changing a string of 12 chr's to a stream of 96 bits and then manipulating these. Currently I work in vb (vb2008). Would it be...
3
by: smitamone | last post by:
Hallo! I have to do the following tasks: 1) I need to read first 8 bytes from file 2) Get all 64 bits for editing 3) Change some bits and save its back to file basically i want to compress...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.