Thread: file

  1. #1
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159

    Unhappy file


    i'm new in c++ programming

    Code:
    int main()
    {
    char m[20];
    fstream file("c:\\test\\test.txt",ios::ate | ios::out | ios::in )
     /* i want a function to create test if doesn't exist */ 
    get(m)
    file << m;
    file.close();
    
    sorry about my english because i unse a translator 
     
    posted by Robc

    writing or update then a nonexistent file is created if possible. That means if you use ios_base:ut at all in the mode and the file doesn't exist, the program will attempt to create it.

  2. #2
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159

    i want a function that create directory [test] no [file.txt]

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    2
    are you just trying to create a new file, or make a new folder or directory
    if you just wnt to create a file you can use this, you have to iclude the header file fstream.h (#include <fsteam.h>)
    Code:
    {
    	ofstream file;
    	
    	file.open("filename.txt");		//open a file
    	
    	file<<"your words go here\n"<<75;    //writes to a file
    	
    	file.close();			 //close it
    }
    if you want to create a directory im not sure on that one

  4. #4
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    I think he's saying he wants it to create a DIRECTORY. Called test with a file in it. Not sure how that would work.

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    mkdir
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  6. #6
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    mmmm right

    Code:
    #include <iostream>
    #include <fstream>
    #include <stdlib.h>
    using namespace std;
    
    int main()
    {
      system("mkdir c:\\test");
    
      ofstream file("test.txt");
    
      file << stuff;
    
      file.close;
     
      return 0;
    }

  7. #7
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159
    thanks vicious
    ............................

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  4. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM