top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to covert unsigned char[4] to unsigned integer?

+3 votes
213 views
How to covert unsigned char[4] to unsigned integer?
posted Feb 17, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

I would like to explain by using following sample piece of code:
char[4] ch = {'1', '2', '3', '4'};
int i = 0;
n = 4;
for (i = 0; i < n ; i++)
{
i += (ch[i] - '0') * pow(10, n-i-1);
}

Now, i has converted integer value of i

answer Feb 17, 2015 by Harshita
Similar Questions
+1 vote
#include <stdio.h>
int main()
{
  char val=250;
  int ans;
  ans= val+ !val + ~val + ++val;
  printf("%d",ans);
  return 0;
}
+2 votes

A char can not be a +ve or -ve. last bit is signed bit in accumulator.but not useful for CHAR Whats the purpose? of doing it.

+6 votes

Write a program to reverse the bits of an unsigned integer ??

...