C/C++ on Linux/Unix

Moderators: Lundin
Number of threads: 314
Number of posts: 633

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
file extension help needed Posted by rocky811 on 20 Jun 2008 at 12:48 PM
hi ,
I have written a program , a part of which is below which generates output files with extension 1.dat , 2.dat n so on ... but i want output something like .. prog1.dat and prog2.dat .... so on .... can someone help me out with this how i can get output filenames like that:

while(!infile2.eof())
{
i++;
sin.str("");
infile1.clear();
infile1.seekg(0,ios::beg);
sin << i;

std::string val(sin.str());
cout<<"i: " <<val<<endl;
std::string val1;
val1 = val+".dat";
outfile.open(val1.c_str());
Report
Re: file extension help needed Posted by zibadian on 20 Jun 2008 at 3:42 PM
: hi ,
: I have written a program , a part of which is below which
: generates output files with extension 1.dat , 2.dat n so on ...
: but i want output something like .. prog1.dat and prog2.dat .... so
: on .... can someone help me out with this how i can get output
: filenames like that:
:
: while(!infile2.eof())
: {
: i++;
: sin.str("");
: infile1.clear();
: infile1.seekg(0,ios::beg);
: sin << i;
:
: std::string val(sin.str());
: cout<<"i: " <<val<<endl;
: std::string val1;
: val1 = val+".dat";
: outfile.open(val1.c_str());
:
Change the red line above into:
    val1 = "prog"+val+".dat"



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.