---
title: "How do I check a string is number or not in c language?"  
description: "How do I check a string is number or not in c language?"  
author: "Mukul Goenka"  
published: 2021-11-08  
updated: 2021-11-08  
canonical: https://www.mindstick.com/forum/156807/how-do-i-check-a-string-is-number-or-not-in-c-language  
category: "c#"  
tags: ["c#", "java"]  
reading_time: 1 minute  

---

# How do I check a string is number or not in c language?

How do I [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) is number or not in [java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming) [language](https://www.mindstick.com/startup/28/preply-the-fast-growing-platform-transforming-language-learning)?

## Replies

### Reply by Ravi Vishwakarma

In this program validate the string for accepting the digit value.

## Program

```
#include <stdio.h>int check_digit(char *str);int main(){    char *str ='45n82';    if(check_digit(str))        printf('%s is digit',str);    else        printf('%s is not digit',str);            return 0;}int check_digit(char *str){    int isDigit = 0;    while (*str) {        if (*str == '\0')             break;        else if(*str>=48 && *str<=57)            isDigit = 1;        else{            isDigit = 0;            break;        }        str++;    }    return isDigit;}
```

## Output

45n82 is not digit


---

Original Source: https://www.mindstick.com/forum/156807/how-do-i-check-a-string-is-number-or-not-in-c-language

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
