im writing my own assembler and the only thing that is going wrong is reading the input from the source file I dont no how to read one word at a time so if i have a statement like
mov 25 3
it can read mov store it than 25 store it than 3 i just need the 3 or 4 lines of code to do that also should i store it in arrays or strings?
cam875
1
Junior Poster
Recommended Answers
Jump to Postuse fstream's >> operator to read just one word at a time.
Jump to Postfstream will skip white space for you -- you don't have to do a thing
ifstream in("filename"); string word; int val1, val2; while( in >> word >> val1 >> val2) { // do something with these values }
All 6 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
cam875
1
Junior Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
cam875
1
Junior Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
cam875
1
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.