: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
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscstring.h.html#PetscStrncmp">include/petscstring.h</A>

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


---
[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)  
