C++ Standards, Extensions, and Interop


How do I edit nibbles in my program?


And how would I write the nibbles to a file, how would I be able to make the total of them divisable by two so that whole bytes get writen?
Of course you cannot do that directly, but...you can use masking and shifting. You cannot write a nibble, you need to write bytes. You are looking from the wrong angle with the last question.
N bytes = 2N nibbles. That is always true. If you have a value that is less than 16, the other nibble is zero, right?
unsigned char theByte = 0xaf;
unsigned char theLittleNibble = theByte & 0x0f;
unsigned char theBigNibble = theByte >> 4 & 0x0f;
unsigned char theNewByte = theBigNibble << 4 | theLittleNibble;
You need to write them 4 at a time (so you write a full byte). In the case when you have a remainder, you may need to read the existing byte from the file, modify the bits you care about, then write the byte back out.Microsoft Test - http://tester.poleyland.com/
You should also clarify if it is a UK nibble or a US nibble. They are different number of bits.
http://en.wiktionary.org/wiki/nibbleMicrosoft Test - http://tester.poleyland.com/
Thanks for the help
U.S. nibble
Josh Poley [MSFT] wrote:
>
>You should also clarify if it is a UK nibble or a US nibble. They are different number of bits.
>
>http://en.wiktionary.org/wiki/nibble
I would argue that Wiktionary is wrong. I've been computing for a very
long time, and I have never in my life heard "nibble" or "nybble" used to
refer to anything other than 4 bits.
--
Tim Roberts, timr#probo.com
Providenza & Boekelheide, Inc.
Tim Roberts, DDK MVP

Related Links

Beginner c++ question--Bitwise enumerations
int i = 2; Is this the Assingment Operator here ?
How do you define a template class's constructor outside the class
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
How to use another variable from another Form in VisualC++
Accessing a member through a pointer
How to copy one char* array into another one?
definition of dllimport static data member not allowed
LockFile problem
mspdbsrv.exe consuming over 1.4GB
Visual c++, how to find a file in certain folder and print its name?
abstract classes in cpp
Convert float to String
LNK1104 error - DEBUG vs. RELEASE
recvfrom on a udp socket does not receive in release build/mode
Error C2039, error c2065 with compiler setting at /clr

Categories

MSDN
Using Forums
SharePoint
BizTalk Server
JScript and Scripting
Microsoft Sync Framework
Windows Server
Windows Live Developer
Dynamics
Windows Hardware Devel...
Bing Ads API: Development
Unified Communications
Expression
Archive
In-App Advertising (Ad...
Microsoft Partner Center
Where is the Forum For…?
Forums Issues (not pro...
MSDN and TechNet Profi...
XboxLiveDevelopment
User Interface develop...
Outlook for Developers
Office 365 for Developers
Developing Apps for Sh...
SharePoint 2010 - Usin...
SharePoint Legacy Vers...
Azure Management Portal
Azure Backup
Azure Scripting and Co...
Azure Log Analytics
Azure Logic Apps
Azure Disk Encryption
Azure Database for Pos...
Publishing Apps for th...
Visual Studio Visualiz...
Team Foundation Server...
Visual FoxPro General
Code Contracts
HealthVault Developer
Small Basic
Microsoft Robotics - H...
Visual Studio Smart De...
SQL Server Analysis Se...
SQL Service Broker
SQL Server Database En...
SQL Server Data Wareho...
SQL Server Migration
Windows Forms Designer
Windows Live Writer: D...
Dynamics 365 for Custo...
MSDN Subscriptions Fee...
MSDN, TechNet and Expr...
Bing Maps WPF, WP7/8/8...
Windows File Sharing P...
Exchange Server Protocols
Office Protocols
Office XML, ODF, and B...
Visio General Question...
Exchange Server Develo...
Expression Encoder
Expression Studio
Expression Media
Microsoft Online Syndi...
Windows Performance To...
Retired SharePoint Ent...
ASMX Web Services and ...
Charts & Reports in th...
Getting Started With V...
Managed Extensibility ...
Microsoft ESP Platform...
Monitor, Alert and Aut...
Network Class Library ...
Office Live Small Busi...
Search Server: Frequen...
Server Core Developers
Silverlight (formerly ...
Small Business Applica...
Share your How to samp...
SQL Server 2014 Data Q...
Team Foundation Server...
Tellme Studio (retired)
Tools for Windows Stor...
Visual Basic 2008 (Pre...
Visual J# General (Ret...
Visual Studio Team Ser...
Visual Studio 2008 SP1...
Visual Studio Applicat...
Visual Studio Gallery ...
Visual Studio Performa...
Visual Studio Tools fo...
Windows Live Data Deve...
Windows Live Search: D...
Working with Data in W...
XNA Framework
Reporting
Kinect for Windows v2 SDK

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile