> For the complete documentation index, see [llms.txt](https://docs.hex-rays.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hex-rays.com/8.4/developer-guide/idc/idc-examples/structures-manipulation.md).

# Structures manipulation

This program demonstrates basic structure manipulation.

```
#include <idc.idc>

static main() {
  auto idx;

  for ( idx=GetFirstStrucIdx(); idx != -1; idx=GetNextStrucIdx(idx) ) {
    auto id,m;
    id = GetStrucId(idx);
    if ( id == -1 ) Fatal("Internal IDA error, GetStrucId returned -1!");
    Message("Structure %s:\n",GetStrucName(id));
    Message("  Regular    comment: %s\n",GetStrucComment(id,0));
    Message("  Repeatable comment: %s\n",GetStrucComment(id,1));
    Message("  Size              : %d\n",GetStrucSize(id));
    Message("  Number of members : %d\n",GetMemberQty(id));
    for ( m = 0;
	  m != GetStrucSize(id);
	  m = GetStrucNextOff(id,m) ) {
      auto mname;
      mname = GetMemberName(id,m);
      if ( mname == "" ) {
        Message("  Hole (%d bytes)\n",GetStrucNextOff(id,m)-m);
      } else {
        auto type;
        Message("  Member name   : %s\n",GetMemberName(id,m));
        Message("    Regular cmt : %s\n",GetMemberComment(id,m,0));
        Message("    Rept.   cmt : %s\n",GetMemberComment(id,m,1));
        Message("    Member size : %d\n",GetMemberSize(id,m));
	type = GetMemberFlag(id,m) & DT_TYPE;
	     if ( type == FF_BYTE     ) type = "Byte";
	else if ( type == FF_WORD     ) type = "Word";
	else if ( type == FF_DWRD     ) type = "Double word";
	else if ( type == FF_QWRD     ) type = "Quadro word";
	else if ( type == FF_TBYT     ) type = "Ten bytes";
	else if ( type == FF_ASCI     ) type = "ASCII string";
	else if ( type == FF_STRU     ) type = form("Structure '%s'",GetStrucName(GetMemberStrId(id,m)));
	else if ( type == FF_XTRN     ) type = "Unknown external?!"; // should not happen
	else if ( type == FF_FLOAT    ) type = "Float";
	else if ( type == FF_DOUBLE   ) type = "Double";
	else if ( type == FF_PACKREAL ) type = "Packed Real";
	else				type = form("Unknown type %08X",type);
	Message("    Member type : %s",type);
	type = GetMemberFlag(id,m);
	     if ( isOff0(type)  ) Message(" Offset");
	else if ( isChar0(type) ) Message(" Character");
	else if ( isSeg0(type)  ) Message(" Segment");
	else if ( isDec0(type)  ) Message(" Decimal");
	else if ( isHex0(type)  ) Message(" Hex");
	else if ( isOct0(type)  ) Message(" Octal");
	else if ( isBin0(type)  ) Message(" Binary");
	Message("\n");
      }
    }
  }
  Message("Total number of structures: %d\n",GetStrucQty());
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hex-rays.com/8.4/developer-guide/idc/idc-examples/structures-manipulation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
