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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:03:07+00:00 2026-05-25T15:03:07+00:00

Assignment: Read in info from text file (done) Retrieve only parts of text file

  • 0

Assignment:

  1. Read in info from text file (done)

  2. Retrieve only parts of text file using substr method (done)

  3. Store info into instance variables (need help)

Here is the code I am having trouble with:

string* lati;
lati = new string(data.substr(0, data.find_first_of(",")));

double* latDub;
latDub = new double(atof((char *)lati));

this->latitude = *latDub;
  1. I need to store the latitude into the instance variable latitude.

  2. The variable data is the read-in text file.

  3. this->latitude is declared as a double.

I have tested and the variable lati is the correct value, but once I try to convert it into a double the value changes to 0 for some reason. I am specifically supposed to use the atof method when converting!

  • 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-25T15:03:07+00:00Added an answer on May 25, 2026 at 3:03 pm

    (char *)lati doesn’t do what you think it does. What you’re clearly trying to do there is get the char sequence associated with lati, but what you’re actually doing is just squeezing a string* into a char* which is all kinds of bad.

    There’s a member function on std::string that will give you exactly what you want. You should review the documentation for string, and replace (char *)lati with a call to that function.

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

Sidebar

Related Questions

As part of an assignment, I need to read data from a binary file
So for an assignment I have to read from a input file that is
I have an assignment which says I have to read from file the distances
I have created a method in my java assignment to write into a file
I have an assignment where I need to read a text file and then
Assignment: Write a C++ program to read the menu information from menu.txt. First letter
I have an assignment to read a file and output the average test scores.
I have a class assignment to read in data using Scanner. import java.util.Scanner; public
I am working on an assignment that only allows use of low-level I/O (read(),
Hey. So my assignment was to read the text files to form the matrices

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.