---
title: 属性信息写入
description: "- char类型属性信息写入。"
url: https://www.hikunpeng.com/document/detail/zh/hpchistory/hpckit/develop2400/userg_hyperio_0071.html
sourcePath: /source/zh/hpchistory/hpckit/develop2400/userg_hyperio_0071.html
indexId: af22f0627a8bd8dbdcef19a10be621a5306ae36b14cc296235b07bddb620717064
---
# 属性信息写入

#### 函数定义

- char类型属性信息写入。
  int ncmpi_put_att_text(int fileId, int varId, const char* name, MPI_Offset nelems, const char* buf);

- int类型属性信息写入。
  int ncmpi_put_att_int(int fileId, int varId, const char* name, int xType, MPI_Offset nelems, const int* buf);

- float类型属性信息写入。
  int ncmpi_put_att_float(int fileId, int varId, const char* name, int xType, MPI_Offset nelems, const float* buf);

- double类型属性信息写入。
  int ncmpi_put_att_double(int fileId, int varId, const char* name, int xType, MPI_Offset nelems, const double* buf);


#### 参数

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| fileId | 文件ID | 非负整数 | 输入 |
| varId | variable ID | 非负整数 | 输入 |
| \*name | 属性名称 | 非空，长度小于256字节 | 输入 |
| nelems | 写入信息的长度 | 非负整数 | 输入 |
| \*buf | 写入信息的内存的指针 | 非空 | 输入 |
| xtype | 写入的类型 | 非负整数 | 输入 |


#### 返回值

- 成功：返回NC_NOERR。
- 失败：返回错误码。


#### 错误码

| 错误码 | 描述 |
| --- | --- |
| NC\_EBADID | 无效ncid |
| NC\_EBADNAME | 无效名称 |
| NC\_ENOMEM | 空指针或无效内存 |
| NC\_EINVAL | 无效的参数 |
