Let's say foo is a struct with some variable length, typical of various MVS
data areas.

struct foo *pFoo;

If you say pFoo++ it increments pFoo by the declared static length of a foo,
not by 1. Increments by the declared length of struct foo.

If bar is an integer that has the actual length of this particular foo and
you want to increment pFoo by that amount, then you could code

pFoo = (foo *)((char *)foo + bar);

You are casting foo to a char* so ++ would add one to it. Then you add bar
(absolute value in bar) and then cast back to a foo* so you can assign it to
pFoo.

My two templates "automate" that (C++ only).

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On
Behalf Of Barkow, Eileen
Sent: Thursday, February 8, 2018 8:45 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Silly C problem adding hex 6C

Thank you Charles and Seymore. I thought that the problem had something to
do with adding to pointers but I could not find any doc about it in the
manuals.
I am still not sure that I understand how to fix it but I will try based on
your info.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to