Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading and writing from external files

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hey!

I'm new to C++, and I'm trying to make a program that reads all lines in a text file, which contains ip addresses, so I can use &quot;route add <ip address> <gateway's ip>&quot;. I tried to make a batch file, but the route command doesn't like to be followed up by another route command... Can someone plz help me?

Thanx a bunch!
 
Sounds like something you have to hard code. Maybe read in each line into a string then check each character. If there are more than three periods in a line then check how far apart they are. If they are three characters apart then you have one IP address and so on....

Its a bit tedious but if you have one file with IP addresses and other stuff you have to filter each line.

Good luck

 
did you ever find a solution to your problem, id so please provide me with the details. I have the same issue that needs to be address..

Thanks.
chuet@ideotron.ca
 
I think you would have more luck finding a solution to your problem if you would copy and paste your example text file in this forum. The problem sounds simple enough. You want to read in a text file, then just extract all the ip addresses from it. I am assuming that there are other lines of text in the file that are just obstacles to get by. This sounds like a job for a perl script. But anything coded in perl can be coded in C/C++. The code will just be a whole lot longer. Paste your text file and answers will come. Mike L.G.
mlg400@blazemail.com
 
I had challangeD someone in reading and writing the contents of a file. Its a simple program that reads in the file then reverses each line and then flips the page. I HAD DONE IT C++ , THE OTHER PERSON HAS DONE IT IN DELPHI. WHAT IS THE FAST WAY TO HANDLE FILE I/O? (OTHER THAN USING WINDOWS API FUNCTIONS? BELOW IS AN Example)

SAMPLE INPUT
-----------------

HELLO THIS IS A TEST FOR
BETWEEN USING C++ AND DELPHI



OUTPUT
-------------------
IHPLED DNA ++C GNISU NEEWTEB
ROF TSET A SI SIHT OLLEH


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top