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 7029677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:34:13+00:00 2026-05-28T00:34:13+00:00

I am working on code that takes as input a ton of ascii text

  • 0

I am working on code that takes as input a ton of ascii text defined by specific protocol. The original author interpreted “string(1)” datatypes in the original protocol as chars in the code.

There have been a lot subtle bugs in corner cases where you have code such as:

char theChar = whatever();
if(theChar == 7) {...} 

where was was really meant was:

if(theChar == '7') {...}

In order to attempt to catch all of these at once, is there a way to disable the implicit casting to ‘char’? If not, what is the best way to go about tracking all of these down?

  • 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-28T00:34:14+00:00Added an answer on May 28, 2026 at 12:34 am

    You should be able to write a trivial replacement class for char (which holds a char as its data, and provides a few cast operators to allow it to be used as if it were a char) that doesn’t allow implicit casts to/from ints, and then do a search and replace of ‘char’ with the ‘mychar’. This will throw up compiler errors that you can fix, and then if you wish you can revert the code to using char again, or stick with your class.

    This is a good example of a place where temporary use of macros is so useful in c++…

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

Sidebar

Related Questions

I'm working on an x86 asm obfuscator that takes Intel-syntax code as a string
I working on an app that takes input from a text field and puts
I'm working on code that's supposed to start the screensaver defined by the user
I'm making this function that takes a string input, converts it to an int,
I'm working with an interface that takes type Object as its input. This is
I'm working with a bit of html and Javascript code that I've taken over
I'm working on code that does nearest-neighbor queries. There are two simple ideas that
I'm working some code that inserts csv rows into an SQLite database using Python.
I've recently been working with code that looks like this: using namespace std; class
I'm working on some code that uses the System.Diagnostics.Trace class and I'm wondering how

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.