⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 processapplication.cpp

📁 Think in C++ 第二版源码
💻 CPP
字号:
//: C26:ProcessApplication.cpp

// From Thinking in C++, 2nd Edition

// Available at http://www.BruceEckel.com

// (c) Bruce Eckel 1999

// Copyright notice in Copyright.txt

//{L} FormData

#include "FormData.h"

#include "../require.h"

using namespace std;



const string from("Bruce@EckelObjects.com");

const string replyto("Bruce@EckelObjects.com");

const string basepath("/home/eckel");



int main(int argc, char* argv[]) {

  requireArgs(argc, 1);

  FormData fd(argv[1]);

  char tfname[L_tmpnam];

  tmpnam(tfname); // Create a temporary file name

  string tempfile(basepath + tfname + fd.email);

  ofstream reply(tempfile.c_str());

  assure(reply, tempfile.c_str());

  reply << "This message is to verify that you "

    "have been added to the list for the "

    << fd["subject-field"] << ". Your signup "

    "form included the following data; please "

    "ensure it is correct. You will receive "

    "further updates via email. Thanks for your "

    "interest in the class!" << endl;

  FormData::iterator i;

  for(i = fd.begin(); i != fd.end(); i++)

    reply << (*i).first << " = " 

       << (*i).second << endl;

  reply.close();

  // "fastmail" only available on Linux/Unix:

  string command("fastmail -F " + from + 

    " -r " + replyto + " -s \"" + 

    fd["subject-field"] + "\" " +

    tempfile + " " + fd.email);

  system(command.c_str()); // Wait to finish

  remove(tempfile.c_str()); // Erase the file

} ///:~

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -