:orphan:
# PetscStrncmp
Compares two strings, up to a certain length
## Synopsis
```
static inline PetscErrorCode PetscStrncmp(const char a[], const char b[], size_t n, PetscBool *t)
```
Not Collective, No Fortran Support
## Input Parameters
- ***a -*** pointer to first string
- ***b -*** pointer to second string
- ***n -*** length to compare up to
## Output Parameter
- ***t -*** `PETSC_TRUE` if the two strings are equal, `PETSC_FALSE` otherwise
## Note
If `n` is `0`, `t` is set to `PETSC_FALSE`. `a` and/or `b` may be `NULL` in this case.
## See Also
`PetscStrgrt()`, `PetscStrcmp()`, `PetscStrcasecmp()`
## Level
intermediate
## Location
include/petscstring.h
## Examples
src/dm/field/tutorials/ex1.c
src/dm/impls/stag/tutorials/ex4.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscstring.h)
[Index of all Sys routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)