file

This is a discussion on file within the C++ Programming forums, part of the General Programming Boards category; 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 ...

  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,600
    mkdir
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  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, 09:57 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21