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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP commands in c/c++

Status
Not open for further replies.

felixsoft

Programmer
Nov 8, 2001
15
0
0
US
How can you use FTP commands in a c/c++ dos app.
All I can get it to do is connect using
system(const *char);
I have been working on making a firewall but I can't figure out how to access ports either can anyone help me on these topics?

Okay I also need to know how to read and right to a *.ini file. I'm a newbie to internet programming
 
What are you trying to do with FTP? Could you create a file with the FTP commands then call it with the -s switch? Then you could do:
Code:
system ("FTP -s: mycommand.txt");

As far as reading and writing to .ini files, I prefer the standard C++ streams. You would need to
Code:
#include <fstream.h>
. You can do something like this to read a ini file:
Code:
std::ifstream IniFile; // stream set up
IniFile.open(&quot;MyFile.ini&quot;);

// Check File
if (!IniFile)
{
    // Something went wrong, do something about it here
}
else
{
    // File opened OK. Now get data
    // Get the lines and check for comments and import/export directories
    std::string ALine;

    // Proceed as long as there is data;
    while (std::getline(IniFile, ALine, '\n'))
    {
        // process each line here
    }
}

// Done! Close up
IniFile.close();

To write to the file, you could use
Code:
std::ofstream IniFile;
. Then you could either overwrite the whole file or just append. It depends on the options you use with fstream.
James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top