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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:18:35+00:00 2026-05-14T14:18:35+00:00

I have been reading SO for some time now, but I truly cannot find

  • 0

I have been reading SO for some time now, but I truly cannot find any help for my problem.

I have a c++ assignment to create an IAS Simulator.

Here is some sample code…

0   1   a
1   2   b
2   c
3   1
10  begin
11  . load a, subtract b and offset by -1 for jump+
11  load M(0)
12  sub M(1)
13  sub M(3)
14  halt

Using c++, I need to be able to read these lines and store them in a “memory register” class that I already have constructed…

For example, the first line would need to store “1 a” in register zero.

How can I parse out the number at the line beginning and then store the rest as a string?

I have setup storage using a class that is called using mem.set(int, string);. int is the memory location at the beginning of the line and string is the stored instruction.

Edit: Some Clarifications:

  • I must use standard libraries
  • the grammar for the input file is here: http://www.cs.uwyo.edu/~seker/courses/2150/iascode.pdf
  • The loader will overwrite duplicate line entries. That means the first line 11 in the sample will be overwritten by the second.
  • 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-14T14:18:36+00:00Added an answer on May 14, 2026 at 2:18 pm

    Splitting the leading number and the rest of the line is not too difficult of a task. Use something like getline to read one line at a time from your input file, and store the line in a string char cur_line[]. For each line, try something like this:

    • Declare a pointer char* pString and an integer int line_num
    • Use the strstr function to find the first whitespace character, and assign the result to pString.
    • Move pString forward one character at a time until it points to a non-whitespace character. This is the start of the string containing the “rest of the line”.
    • Use atoi on cur_line to convert the first entry in the string to an integer, and store the results in line_num
    • Now, you should be able to call your function like mem.set(line_num, pString)

    Interpreting those strings is going to be much more difficult, however…

    Edit: As Mike DeSimone mentions, you can combine the strstr and atoi steps above if you use one of the strto* functions instead of atoi.

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

Sidebar

Related Questions

I have been using Git for some time now to manage my own personal
I have been interested in learning Rails for some time now and feel now
OK, So i have been watching some MVC vids and reading some bits. I
I've been wanting to improve my regex skills for quite some time now and
I have been using Git for my version control for a while now, but
I have been reading through the C++ FAQ and was curious about the friend
I have been reading the MSDN documentation on subclassing and I have been successful
I have been reading about the differences between Table Variables and Temp Tables and
I have been reading the proper article in MSDN, Strong-Named Assemblies and a related
I have been reading through the CodePlex supported open source licenses, i couldn't quite

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.