Code::blocks only shows console, when trying use fopen

I searched all over internet, but couldn't find a answer.
Here's the code its pretty simple.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  #include <cstdio>
using namespace std;
int main ()
{
    FILE * open;
    open = fopen("C:\\Users\\Sotho\\CodeBlocks\\gta\\example.txt","r");
    if(open!=NULL)
    {
        fputs("file",open);
        fclose(open);
    }



}

Could you tell me what is wrong?
You open the file for input "r" and then attempt to output to it. If you want an output file, use mode "w".
i think your fputs syntax is wrong:

look at this article:
http://www.cplusplus.com/reference/cstdio/FILE/

And also this for fputs:
http://www.cplusplus.com/reference/cstdio/fputs/
i think your fputs syntax is wrong:

Could you explain what exactly is wrong?

This is the function declaration, which seems to match the code originally posted above.int fputs ( const char * str, FILE * stream );
Last edited on
@chervil; oh no.,, i'm sorry i'm wrong i've just got confuse what he wants to do with the program
Wow, thanks guys, I am such an idiot.
Topic archived. No new replies allowed.