-
March 8th, 2013, 09:44 AM
#1
Why "char" is inside "int" loop?
Can someone explain this to me:
Code:
......
static char str[BIG_STRING];
static char str_copy[BIG_STRING];
char **words;
int max_words = 10;
int num_words = 0;
char *ptr,*ptr2;
char *result;
....
for (ptr = str, ptr2 = str_copy; *ptr != '\0'; ptr++, ptr2++)
{
*ptr2 = *ptr;
....
}
I'm confused with this last [for] loop;
How is ptr++ applied for non-integer value? Ptr is clearly a char, it comes from str, which reads string line from file.
I come from C# background, I have never met for...loop which irretates by using [somechar]++, not [someinteger]++;
What is actually going on there?
Some other similar example might be:
Code:
(iColor+(_parts[j]%length)*3),
where iColor is static unsigned char iColor[] array;
That has no sense to me. I would expect to see iColor[somevalue] + (_parts[j]%length)*3), but here in C++ I sometimes see that integer is being added directly to the array. What does it mean, what happens?
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|