CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Threaded View

  1. #1
    Join Date
    Dec 2008
    Posts
    8

    Problem with ofstream...

    Hi knowledgeable C++ programmers!
    I'm having problems with this program because it is giving me an error about how the file cannot read #include <ofstream>

    please do take a look at the program...

    // Program 16.cpp : Defines the entry point for the console application.
    //

    #include "stdafx.h"
    #include <string>
    #include <ofstream>
    #include <iostream>
    using std::cout;
    using std::cin;
    using std::endl;

    int main ( )
    {
    int i;
    struct record
    {
    char name[15];
    float amt;
    };
    record master[10] = {{"Helen", 10}, {"Julie", 20}, {"Lena", 30}, {"Alan", 40}, {"Annie", 50}, {"May", 60},
    {"Lee", 70}, {"Sam", 80}, {"June", 90}, {"Bill", 100}};
    record trans[7] = {{"Lena", 10}, {"Julie", 5.75}, {"Lee", 15.02}, {"Ed", 40}, {"Julie", 10.00}, {"Art", 5.00},
    {"Bill", 7.32}};
    ofstream foutmaster("master.dat");
    ofstream fouttrans("trans.dat");

    for (i=0; i<10; i++)
    {
    foutmaster << master.name[i] << master.amt[i] << endl;
    }

    for (i=0; i<7; i++)
    {
    fouttrans << trans.name[i] << trans.amt[i] << endl;
    }

    foutmaster.close("master.dat");
    fouttrans.close("trans.dat");

    }

    I'm using Visual C++ 2005

    1>------ Build started: Project: Program 16, Configuration: Debug Win32 ------
    1>Compiling...
    1>Program 16.cpp
    1>c:\documents and settings\wonwoo\my documents\visual studio 2005\projects\program 16\program 16\program 16.cpp(6) : fatal error C1083: Cannot open include file: 'ofstream': No such file or directory
    1>Build log was saved at "file://c:\Documents and Settings\Wonwoo\My Documents\Visual Studio 2005\Projects\Program 16\Program 16\Debug\BuildLog.htm"
    1>Program 16 - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Attached Images Attached Images  

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