Read a file and store strings into arrays?

Hello.
I am new to this forum! Hopefully I can get some help with some basic programming stuff. Im a working on a project....Here are the requirements

1)Read in the file

2)Seperate the strings into 2 substrings and store them as arrays (Parrameters[x] and Values[x]

3)Store "#" Comments as another sepearte array comments[x]

4)Change two parameters value : delayTime = 10 and defaultPortSpeed = 2400;

5) Save the updated file with comments in the same posistion as original file


Here is a sample input file:

#Simulator Configuration File
#
serialPortName=COM1
srcPort=2222
delayTime=5000
runDuration=2
destPort=4444
MessageCount=10
sourceIPAddr=192.168.1.97
dataRate=1000
sourcePort=3333
destIPAddr=192.168.1.99
hostName=Test
dataSource=DataFile
defaultPortSpeed=9600
dataFormat=longname
dataFileName=C:\Temp\File.txt
localIPAddr=127.0.0.1

Last edited on
Sorry...forgot to mention that I have read in the file and have seperated the 2 substrings in step 2. Im not sure if I have done the seperation correct, because I am storing the comments as part of my parameter and value arrays...

My Code

while(inFile)
{
getline(inFile, tempParameter);

/*if ('#')
{
cout << " found comment" << endl;
ConfigINI::comments[x];
cout << "Comment = " << comments[x];
}*/


equalSign = tempParameter.find("=");
int size = sizeof(tempParameter);

ConfigINI::iniValue[x]=tempParameter.substr(equalSign+temp1.length(), tempParameter.length());

ConfigINI::iniParameter[x]=tempParameter.substr(0,equalSign);


cout << "Value = " << iniValue[x]<< endl;
cout << "Parameter = " << iniParameter[x]<<endl;

x++;
}
http://www.cplusplus.com/forum/articles/1295/
You've not asked a question.
I think his question is: How would you go about creating a base and derive class that would meet all the requirements listed above.


Hey athicks07, I have this same project due Wednesday. If you get any information on how to do this project, will you please post it here, or let me know through angel....Chace Walker. I need all the help I can get. Thanks.
Last edited on
Topic archived. No new replies allowed.