Newby Question: Why cant I open and write to a file using Cygwin C++ on a Vista OS, please help RRS feed

  • Question

  • Hi everyone,

    I am very new to C++ & programing in general and I downloaded Cygwin and wrote a few programs that worked.  Now using Cygwin C++ I cannot open a new file so I am thinking that the interface between Cygwin and Vista is not talking.  Maybe I am missing something obvious but the program compiled but did not create a file that I know of since I did a computer search and nothing came up.  I would appreciate any tips you could give me, thanks.
    My code

    #include (iostream)
    #include (fstream)
    using namespace std;

    int main(){

    ofstream testFile; ("c:\\Desktop\\students.dat");

    testFile<<"This data is just testing this testfile: "<<endl;


    return 0;
    • Moved by nobugz Wednesday, July 9, 2008 8:26 PM Cygwin not supported here
    Wednesday, July 9, 2008 12:05 AM

All replies

  • CFile file; 
    CFileException e; 
    char * ch; 
    int d; 
    CString config; 
    if( !file.Open( _T("C:\\text doc name.txt"), CFile::modeCreate | CFile::modeReadWrite | CFile::shareDenyNone , &e )) 
                  ch = (char*)malloc( config.GetLength() + 1024 ); 
                  for( d = 0; d < config.GetLength(); d++ ) 
              ch[d] = config.GetAt( d ); 
              ch[d] = 0; 
              ch[d+1] = 0; 
    file.Write(ch, d ); 

    Wednesday, July 9, 2008 1:05 AM