Skip to main content
`Ctrl`+`K`

# 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/impls/stag/tutorials/ex4.c
src/dm/field/tutorials/ex1.c

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages