Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8915831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:04:51+00:00 2026-06-15T05:04:51+00:00

I have a pointer to a char array. I want to increase it until

  • 0

I have a pointer to a char array. I want to increase it until it will not point at a digit / number (represented as a char in the char array).

For example, if pointer points to '2' in this char array:

['1'][' ']['2']['3']['4'][' '][' '][' ']['5']['6']['7']
            ^
         *pointer

I want to increase it until it will point at the first non-digit character – ' ':

['1'][' ']['2']['3']['4'][' '][' '][' ']['5']['6']['7']
                           ^
                        *pointer

I know I can do something like this:

while (*pointer == '0' || *pointer == '1' || *pointer == '2' || ...)
    pointer++;

return pointer;

but it’s pretty long and not elegant at all.

I thought I could use atoi(), which returns 0 when the pointer doesn’t point at a number:

while (atoi(pointer) != 0 || *pointer == '0') //while it still points at a number
    pointer++; //increase the pointer until it will not point at a number

return pointer;

But it doesn’t seem to work. Maybe it’s okay and I have a mistake somewhere else, but anyway I wanted to know:

Are there are any other (better) ways to check whether a pointer to a char array points at a digit / number and increase it until it will point at a non-digit character, in C?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:04:52+00:00Added an answer on June 15, 2026 at 5:04 am

    You should probably use isdigit from ctype.h instead. Something like:

    while (*pointer && isdigit(*pointer))
        pointer++;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pointer to an wide char array, which I want to free.
I have a char array representing a double precision floating point number in hex
I have a pointer to a character array: space=(char**)calloc(100000,sizeof(char*)); for(i=0;i<100000;i++){ space[i]=(char*)calloc(1,sizeof(char)); } such that
I have an array of strings defined like this: char** arrNames; Now I want
I have a 2-dimensional array of pointer to char and initialising it in a
I have a function that has input and pointer to an array of char
Basically, I have an array of char* that I want to pass and modify
I have a char pointer which would be used to store a string. It
I have a global pointer variable char* pointer = new char[500]; /* some operations...
I have a mmap typecast to a char pointer char *ptr; ptr = (char

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.