# PetscViewerStringSetString
sets the string that a string viewer will print to 
## Synopsis
```
#include "petscsys.h"  
PetscErrorCode PetscViewerStringSetString(PetscViewer viewer, char string[], size_t len)
```
Logically Collective on viewer


## Input Parameters

- ***viewer -*** string viewer you wish to attach string to
- ***string -*** the string to print data into
- ***len -*** the length of the string


Note: The function does not copy the string, it uses it directly therefore you cannot free
the string until the viewer is destroyed. If you call `PetscViewerStringSetOwnString()` the ownership
passes to the viewer and it will be responsable for freeing it. In this case the string must be
obtained with `PetscMalloc()`.




## See Also
 `PetscViewerStringOpen()`, `PETSCVIEWERSTRING`, `PetscViewerStringGetStringRead()`, `PetscViewerStringSPrintf()`,
`PetscViewerStringSetOwnString()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/viewer/impls/string/stringv.c.html#PetscViewerStringSetString">src/sys/classes/viewer/impls/string/stringv.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/classes/viewer/impls/string/stringv.c)


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