> 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
