Read the description for clarification. I need to make some changes to the progr
ID: 3617985 • Letter: R
Question
Read the description for clarification. I need to make some changes to the program, the followingchanges are as follows:"symName" should be changed to an array of [990] to storenames in it. also "symAddress" change to [990] array, to store thelocations of each name in the file(which row number is iton).
I don't know how to do that, please help me out the code is asshown below.
//Description: This program reads the Data from the file"tiny2.txt" and outputs the first words on each line // and skips any lines that start with a space,and print out each address of each word. //input: using the input file "tiny2.txt", theprogram will receive the inputs which are lines of strings. #include "stdafx.h" #include <iostream> #include <fstream> #include <string> using namespace std;
int main()
{
ifstream infile;//("tiny2.txt");//initialize the inputfile. int PC= 0;// to count the lines int symAddress = 0;// to store the address of the lines withno spaces from "PC" string symName;// to store the names int symSize = 0;// to indicate the size of the file string name;//to check if the lines starts with space, if notit stores it and assigns it to symName. infile.open("C:\Users\Lunarek\Documents\Visual Studio2008\Projects\homework\homework tiny2.txt");//to open thefile. if(infile.fail()) //is it ok? { cout<<"file did not openplease check it "; system("pause"); return 1; } //outputting label lines. cout << "Label" <<""<<"Address"<<endl; cout<<"======="<<""<<"======="<<endl; while (name !=" ZZZ ")//check if any of thelines is equal to " ZZZ " which is the mark end ofthe line. { getline(infile,name);//read line while(name.substr (0,4)==" ")//check andsee if the input is not equal to space. { PC++;//increment PC. getline(infile,name);//input another line. }; symName=name.substr (0,4);//get the first 4 charactersof the string variable.
symAddress=PC ;//assign the value of PC to thesymAddress to show the right address. symSize++; //increment the size.
cout << symName<<""<<symAddress<<endl;//output the values. PC++;//increment . } return 0; } Read the description for clarification. I need to make some changes to the program, the followingchanges are as follows:
"symName" should be changed to an array of [990] to storenames in it. also "symAddress" change to [990] array, to store thelocations of each name in the file(which row number is iton).
I don't know how to do that, please help me out the code is asshown below.
//Description: This program reads the Data from the file"tiny2.txt" and outputs the first words on each line // and skips any lines that start with a space,and print out each address of each word. //input: using the input file "tiny2.txt", theprogram will receive the inputs which are lines of strings. #include "stdafx.h" #include <iostream> #include <fstream> #include <string> using namespace std;
int main()
{
ifstream infile;//("tiny2.txt");//initialize the inputfile. int PC= 0;// to count the lines int symAddress = 0;// to store the address of the lines withno spaces from "PC" string symName;// to store the names int symSize = 0;// to indicate the size of the file string name;//to check if the lines starts with space, if notit stores it and assigns it to symName. infile.open("C:\Users\Lunarek\Documents\Visual Studio2008\Projects\homework\homework tiny2.txt");//to open thefile. if(infile.fail()) //is it ok? { cout<<"file did not openplease check it "; system("pause"); return 1; } //outputting label lines. cout << "Label" <<""<<"Address"<<endl; cout<<"======="<<""<<"======="<<endl; while (name !=" ZZZ ")//check if any of thelines is equal to " ZZZ " which is the mark end ofthe line. { getline(infile,name);//read line while(name.substr (0,4)==" ")//check andsee if the input is not equal to space. { PC++;//increment PC. getline(infile,name);//input another line. }; symName=name.substr (0,4);//get the first 4 charactersof the string variable.
symAddress=PC ;//assign the value of PC to thesymAddress to show the right address. symSize++; //increment the size.
cout << symName<<""<<symAddress<<endl;//output the values. PC++;//increment . } return 0; }
Explanation / Answer
please rate - thanks //Description: This program reads the Data from the file"tiny2.txt" and outputs the first words on each line // and skips any lines that start with a space,and print out each address of each word. //input: using the input file "tiny2.txt", theprogram will receive the inputs which are lines of strings. #include "stdafx.h" #include #include #include using namespace std; int main() { ifstream infile;//("tiny2.txt");//initialize the input file. int PC= 0;// to count the lines int symAddress[990] = {0};// to store the address of the lines withno spaces from "PC" string symName[990];// to store the names int symSize = 0;// to indicate the size of the file string name;//to check if the lines starts with space, if not itstores it and assigns it to symName. infile.open("C:\Users\Lunarek\Documents\Visual Studio2008\Projects\homework\homework tiny2.txt");//to open thefile. if(infile.fail()) //is it ok? { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.