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

Creating tmpfile() in C++

Status
Not open for further replies.

tewari68

Programmer
Jan 25, 2005
87
US
Hi,
How do we create and perform I/O operations on tmpfile() in C++.
I need to create a tempfile and input some data into it and then send this file through exim.

This is what I want to achieve
Code:
File *pFile;
pFile = tmpfile();
//some code to write to this tmpfile()

//calling exim like this
string adminemail = "admin@puremail.com";
string fromemail = "reports@puremail.com";
string mailcmd = "/usr/sbin/exim -bnq -v ";
string sym = "<";
const char * systemCallExec;
string mcmd = mailcmd + " " + adminemail + " " + fromemail +" " + sym + " " +pFile;
systemCallExec = mcmd.c_str();
system(systemCallExec);
I get the following error message at compile time
Code:
error: no match for 'operator+' in 'std::operator+(const
   std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) [with _CharT =
   char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](" ")
   + pFile'

the error seems to be because pFile is File * type, is there any workaround this.

I want to create a file on the fly and input some data and then email it through exim.

Appreciate any help in this regards.

Thanks,
Tewari.
 
Actually, tmpfile() returns a FILE* pointer, not a File* pointer.
I'm not sure why you're trying to add a FILE* pointer to a string? If you're trying to create a filename for a temp file rather than the file itself, use the tmpnam(), tempnam() or mktemp() function; or you can write your own function if you get bored.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top