Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is it possible to add one or two bytes to a longword pointer?

bytes longword pointer possible
0
Posted

Is it possible to add one or two bytes to a longword pointer?

0

Q: Is it possible to add two bytes or even one byte to a longword pointer? I am using a longword pointer to write longwords to the screen, and I need to add 30 bytes to it to get to the next line. However, I can only add multiples of four bytes to it… A: It is possible using typecasting: ptr = (long*)((char*)ptr + 30); Don’t be afraid, the compiler will generate just addition: everything other is just to satisfy type checking conventions. Or alternatively, you can use even simpler form: (char*)ptr += 30; Although such form is not requested to work in ANSI C standard, the most of compilers (including TIGCC) will accept this.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123