-2

This is my main.cpp:

int main () {
    FILE* file_name;
    file_name= fopen("email1.clear","wb");
return 0;
}

I run it with the ssh (Linux):

g++ main.cpp -o main

but no file has been created. (I must to use: FILE*).

please help.

Maor Cohen
  • 936
  • 2
  • 18
  • 33

2 Answers2

2

> How Do I Compile/Run My Program?

To compile C/CPP program first.cpp, and create an executable file called first, enter:

$ gcc first.cpp -o first

OR

$ cc first.cpp -o first

To execute program first, enter:

$ ./first
Sahal
  • 4,046
  • 15
  • 42
  • 68
0

Well I recomend that you use "a+" instead of wb first of all because "a+" let's you create a file if it doesn't exist and if it does it let's you add stuff in the file. Second well I don't know if you are going to use binary because the b in wb is for binary don't put it if you don't need it. So your code should look something like this:

int main () {
    FILE* file_name;
    file_name= fopen("email1.clear","a+");//or just use "w" bot work
return 0;
}

also the file might been placed where the .cpp is save they are usually saved together.

Gustavo
  • 17
  • 2
  • 6