# PetscObjectGetName
Gets a string name associated with a PETSc object. 
## Synopsis
```
#include "petscsys.h"   
PetscErrorCode PetscObjectGetName(PetscObject obj, const char *name[])
```
Not Collective unless object has not been named yet


## Input Parameters

- ***obj -*** the Petsc variable
Thus must be cast with a (`PetscObject`), for example,
`PetscObjectGetName`((`PetscObject`)mat,&name);
- ***name -*** the name associated with obj



## Note
Calls `PetscObjectName()` if a name has not yet been provided to the object.




## See Also
 `PetscObjectSetName()`, `PetscObjectName()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/objects/pgname.c.html#PetscObjectGetName">src/sys/objects/pgname.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/plex/tutorials/ex11.c.html">src/dm/impls/plex/tutorials/ex11.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/plex/tutorials/ex8.c.html">src/dm/impls/plex/tutorials/ex8.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex10.c.html">src/dm/tutorials/ex10.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/label/tutorials/ex1.c.html">src/dm/label/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex36.c.html">src/snes/tutorials/ex36.c.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/objects/pgname.c)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
