CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009
    Posts
    9

    [RESOLVED] FStream Problem

    Hi
    I cannot write to file ! No errors but nothing happens ...
    This is my code :

    void SaveColors()
    { try
    {
    fstream OutFile;
    OutFile.open("c:\Colors.txt",ios:ut);

    OutFile << TargetCount << endl << endl;

    //Write SceneTargets to output file
    for (int i=0 ; i<TargetCount ; i++)
    {
    OutFile << SceneTargets[i].title << endl;
    OutFile << SceneTargets[i].NumberOfColors << endl ;

    for(int j=0 ; j<SceneTargets[i].NumberOfColors ; j++)
    {
    OutFile << SceneTargets[i].Colors[j].h << " " ;
    OutFile << SceneTargets[i].Colors[j].s << " " ;
    OutFile << SceneTargets[i].Colors[j].v << " " ;
    }
    OutFile << endl ;
    }
    //Write changes to disk
    OutFile.close();
    }
    catch (char* str)
    {
    cout << "Error : Cannot write to file" << endl ;
    }
    }

    Thanks

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: FStream Problem

    Quote Originally Posted by rostamiani View Post
    Hi
    I cannot write to file ! No errors but nothing happens ...
    This is my code :
    Code:
    void SaveColors()
    {	try
    	{
    		fstream OutFile;
    		OutFile.open("c:\Colors.txt",ios::out);
    		...
    }
    It must be:
    Code:
    		fstream OutFile;
    		OutFile.open("c:\\Colors.txt",ios::out);
    Victor Nijegorodov

  3. #3
    Join Date
    Sep 2009
    Posts
    9

    Re: FStream Problem

    Thanks a lot )

    The problem solved !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured