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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:14:30+00:00 2026-05-29T10:14:30+00:00

The error occurs when I try to use the atoi(const char*) function in the

  • 0

The error occurs when I try to use the atoi(const char*) function in the following line…

externalEncryptionRawHolder[u] = atoi(parser.next()); 

The ‘parser’ object is a string parser and the ‘next’ method returns a string. I think the error has something to do with the fact that the string within the ‘atoi’ function isn’t a constant… but I’m not sure. The gist of the error is ‘cannot convert string to const char *’. How can I make my string constant? Any help would be very appreciated (by the way, in case you’re wondering what the index ‘u’ is, this is within a ‘for’ loop).

  • 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-29T10:14:31+00:00Added an answer on May 29, 2026 at 10:14 am

    You have to call c_str() on the string object to get a const char*:

    externalEncryptionRawHolder[u] = atoi(parser.next().c_str());
    

    Note, though, that you should not do this:

    const char* c = parser.next().c_str();
    

    Because c will point to the memory that was managed by the string returned by parser.next(), which gets destroyed at the end of the expression, so then c points to deallocated memory. The first example is ok though because the string is not destroyed until after atoi has returned.

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

Sidebar

Related Questions

I try to use jboss-seam with a db2 database, the following error occurs com.ibm.db2.jcc.a.SqlException:
The error occurs when I try to do this friend std::ostream& operator<<(std::ostream& os, const
When an error occurs in a function, I'd like to know the sequence of
The following error occurs in make, while trying to do incremental builds: make[2]: execvp:
I am getting the following error when an event (Add/Edit/Delete) occurs on my databound
What causes the publish error: fl.getDocumentDOM() has no properties ? The error occurs only
I want to make sure that if any error occurs during the database processing
i have used impersonation in this application. whenever this error occurs i required to
I've got a TCP socket which reads data. When an error occurs when reading
Symptom: Some users cannot successfully POST, most can successfully POST. When the error occurs,

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.