If you're trying to complete a program and don't understand, another thing you could try is to search for other peoples' code that does the same thing. You can then modify/study that code to learn more about the language.
For example, if I wanted to write my own strcpy function and didn't know C well, I might first find this code with Google (simplified):
Code:
void my_strcpy (char *dst, const char *src)
{
while ((*dst++ = *src++))
;
}
I could add print statements before/after expressions I didn't understand. So maybe:
Code:
void my_strcpy (char *dst, const char *src)
{
char *tmp_src = src;
char *tmp_dst = dst;
while ((*dst++ = *src++))
printf("src = \"%s\" | dst = \"%s\"\n", tmp_src, tmp_dst);
}
Or, I could try to modify the while loop and check if the result is the same:
Code:
void my_strcpy (char *dst, const char *src)
{
while (*src)
*dst++ = *src++;
}
Or if I didn't understand the pointer syntax, I would Google it and find this link to help.
Then, without copying, I could write my own code.