r/programminghelp • u/thegodfather444 • Feb 14 '24
C pointers in C
so i'm learning C right now and i have a question about the use of pointers in arithmetic.
so when i declare ptr1 and ptr2 as pointers, and then i write *ptr2=*(ptr2)+ptr1 it works fine.
but if i write *ptr2+=ptr1 which is almost the same as before i get an error. can someone help me understand the += because it seem the problem is there
1
Upvotes
View all comments
Show parent comment
1
u/thegodfather444 Feb 14 '24
If i does ptr2=(ptr2)+ptr1 it works but i i do it with += its not. Is the problem lies in the += operation?