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

  • Home
  • SEARCH
  • 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 3438202
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:09:32+00:00 2026-05-18T08:09:32+00:00

gcc 4.5.1 c89 I have a buffer that is filled with char characters. I

  • 0

gcc 4.5.1 c89

I have a buffer that is filled with char characters. I need to compare them:

This is a sample contents of the buffer:

vote buffer [ 51 ]
vote buffer [ 32 ]
vote buffer [ 49 ]
vote buffer [ 32 ]
vote buffer [ 50 ]
vote buffer [ 32 ]
vote buffer [ 53 ]
vote buffer [ 32 ]

I am trying to get the int equivalent of these char’s that are in the buffer to compare.

#define NUMBER_OF_CANDIDATES 7
if((vote_data.vote_buff[i] > NUMBER_OF_CANDIDATES || vote_data.vote_buff[i] < 1) {
    /* Do something */
}

As you can see it will never be true in the if statement as the range is far greater.

I have tried casting to (int). However, that didn’t solve the problem.

I guess I could calculate from the ascii character set. However, I would rather not add more complexity if I cannot help it.

Many thanks for any advice,

  • 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-05-18T08:09:32+00:00Added an answer on May 18, 2026 at 8:09 am

    If you just want to convert single characters to int, you can use c - '0' (which is equivalent to c - 48). If you want to convert strings of more than a single character, use sscanf()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

gcc 4.4.2 c89 I have this code snippet that I have to repeat in
gcc 4.4.1 c89 I have the following code snippet: #include <stdlib.h> #include <stdio.h> char
gcc 4.4.2 c89 I have a function that has to run (config_relays). It make
gcc 4.4.3 c89 I have some functions that initialize some hardware and return either
gcc 4.4.4 c89 Is there a better way to do this? I have the
gcc 4.4.4 c89 I have the following code and 2 structures that have to
gcc 4.4.4 c89 I have this in my header file. port.h struct struct_tag; int
gcc 4.4.4 c89 I have a program that I am testing. I create a
gcc 4.4.2 c89 I have a wave file: 8000 Hz 16 bit I am
gcc c89 I am getting a stack dump on this line: strcpy(comp->persons->name, Joe); However,

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.