Need clarification on OPS_GetInt

I am a structural engineer, trying to modify source code of one of my software to write my own element.
I came across following code line, that I could not understand:

if (OPS_GetIntInput(&numData, iData) != 0) {
opserr << "WARNING invalid element data\n";
return 0;
}

What the command "OPS_GetIntInput(&numData, &matTag) != 0" suppose to do? numData was an integer declared to be 1 and matTag was a command line argument that need to be passed through the constructor.
I know, it's too little of information, but, I did not to paste the whole code and make it messy. If required, let me know, I will paste the whole code.
Last edited on
The & symbol can be read as "the address of". So you are providing this function with the address of the object instead of the object itself.

What does this mean? It means that the function can manipulate numData or matTag directly. Otherwise, the function would only get a copy of the data stored in numData or matTag.

If you look at the function declaration itself, you'll probably see something like:
int OPS_GetIntInput(int* a, int* b);
This means that a and b are pointers to an int. In the function itself you'll see stuff like:
*a = *b;
The star in this case can be read as "the value at this address". So the value of a is being set to the value of b. The most important thing about this is that you are modifying the original parameters numData and matTag by doing this.
OPS_GetIntInput is a function. This function accepts two parameters.

These two parameters are the address of something called numData, and the object called iData.

The function returns a value - not the data, but something to indicate if it was successful. It will return zero if it is successful.

If the returned value does not equal zero, WARNING invalid element data is sent to the opserr (presumably some kind of logging) and then the return 0; causes whatever function this is part of to finish.

It looks like OPS_GetIntInput is supposed to fetch some data, and if that data is bad, the function ends. I would guess that since &matTag is passed in at the command line, it would be the name of a file that data is to be extracted from. numData could be the amount of data to be read - 1 "something".

Really I'm just guessing based on common practices.

Last edited on
Topic archived. No new replies allowed.