Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

unsigned char getting cutshort

Posted on 2007-03-31
3
Medium Priority
?
243 Views
Last Modified: 2010-04-01
Hello,

I have a small problem,

I have a array of unsigned char, for example lets say this,
0x11 0x22 0x33 0xFF 0x44

I then +1 to each of these using a for loop,
array[i] = array[i]+1;

So it looks like this,
0x12 0x23 0x34 0x00 0x45

But now it gets cut short because of the null char 0x00,
Is there anyway to overcome this problem?
0
Comment
Question by:-Karamja-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 220 total points
ID: 18829512
>> But now it gets cut short

That only depends on how you output the array.

Try this for example :

    unsigned char arr[5] = { 0x11, 0x22, 0x33, 0xFF, 0x44 };
    int i = 0;
    for (i = 0; i < 5; ++i) {
      ++(arr[i]);
    }
    for (i = 0; i < 5; ++i) {
      cout << hex << arr[i] << " ";
    }
    cout << endl;
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 18829515
Can you show your code - and the location where you notice the problem ?
0
 
LVL 2

Author Comment

by:-Karamja-
ID: 18829588
Ok, I was being stupid :(
Your code triggered something in my head though so I guess the points are yours ;)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question