How can i to write in a folder or a driver?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
#include <fstream>
#include <direct.h>
int main (int argc,char *argv[])
{char *b,*a;
const char *c;
 if(argc<2){
 a="C:\\Program Files\\Europa Universalis III Divine Wind\\";
 b="D:\\Europa Universalis III Divine Wind\\";
 c="*\\*.*";
} 
else{
     a=argv[1];
     b=argv[1];
     c=argv[1];
     }
mkdir("D:/Europa Universalis III Divine Wind");
  std::ofstream dosya1(strcat(b,c),std::ios::out | std::ios::binary);
  std::ifstream dosya2(strcat(a,c),std::ios::in | std::ios::binary);
  char d;
  while(dosya2.read(&d,1)&&dosya1.write(&d,1))
  ;
  if(dosya2.eof())
 perror("Read problem from: ");
  if(!dosya1)
  perror("Write problem from: ");
}


I take a system error when i run this codes.I want to write in a folder or a driver or a cd thnx for all exegesis.
Last edited on
If you're trying to just create a file then it's simpler then you are making it look:
1
2
3
4
5
6
7
8
9
10
11
12
#include<iostream>
#include<fstream>

int main(int argc, char *argv[])
{
    std::ofstream OutFile("NameOfFile.txt", std::ios_base::out);

    OutFile << "My Data\n";

    OutFile.close();
    return 0;
}


EDIT: This will drop a file named "NameOfFile.txt" into your relative path. If you want it in a different directory then you need to specify the directory using UNC.
Last edited on
Topic archived. No new replies allowed.