12,076,925 members (46,281 online)
Rate this:
See more:
How to Copy unsigned char* value to unsigned char???
Posted 4-Mar-11 0:29am

Remember that char* is 32 bit and char is 8 bit, anyway you can use memory copy to split the pointer to four char, if that is what you like ...
Gokulnath007 4-Mar-11 5:47am

yes.. how it can be done
Andrew Brock 4-Mar-11 7:38am

char* is an array of characters. char is a single character. Do you want just the first character or do you want to iterate through each character or what?
Gokulnath007 4-Mar-11 7:47am

yes. Want to iterate .

Rate this:

## Solution 1

Are you asking how you do this:
```void GetChar(unsigned char *pointer)
{
unsigned char uc = *pointer;
}```
Because if you are, I think you need to look at your course notes a little more carefully...
Rate this:

## Solution 2

Gokulnath007 wrote:
yes. Want to iterate.

Well, a pointer is basically an array (rather, an array is basically a pointer).
A string is an array of characters followed by the null character `'\0'`.
so,
```char *str = "hello world";
for (int ch = 0; str[ch] != '\0'; ++ch) { //keep going until we hit the '\0'
printf("%c\n", str[ch]); //print a single character and jump to the next line
}```

Top Experts
Last 24hrsThis month
 Jochen Arndt 350 Sergey Alexandrovich Kryukov 344 Richard MacCutchan 340 OriginalGriff 250 F-ES Sitecore 220
 OriginalGriff 2,855 Dave Kreskowiak 2,836 Richard MacCutchan 2,174 CPallini 1,632 Sergey Alexandrovich Kryukov 1,445