# PetscStrncmp
Compares two strings, up to a certain length 
## Synopsis
```
#include "petscsys.h"   
PetscErrorCode PetscStrncmp(const char a[], const char b[], size_t n, PetscBool *t)
```
Not Collective


## Input Parameters

- ***a -*** pointer to first string
- ***b -*** pointer to second string
- ***n -*** length to compare up to



## Output Parameter

- ***t -*** if the two strings are equal





## Fortran Note
Not for use in Fortran


## See Also
 `PetscStrgrt()`, `PetscStrcmp()`, `PetscStrcasecmp()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/utils/str.c.html#PetscStrncmp">src/sys/utils/str.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex4.c.html">src/dm/impls/stag/tutorials/ex4.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/field/tutorials/ex1.c.html">src/dm/field/tutorials/ex1.c.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/utils/str.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)  
