READING and Writing Files

Hello, still kinda of a newbie.

I have a problem.
How come the line "Hello world" wasn't printed out?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <cstring>
#include <fstream>

#define COL_WIDTH 80

using namespace std;

int main(){

    char filename[MAX_PATH + 1];
    char input_line[COL_WIDTH + 1];


    ofstream write("RED.txt");
    write << "Hello world!"<<endl;

    ifstream read("RED.txt");
    read.getline(input_line, COL_WIDTH);


    }


And to be honest, I have no idea what I did. So can someone explain/help me?
That's because you aren't printing anything. You are just writing and reading from a file but not doing anything with what you are getting.
Oh so how would I print it?
And if someone can explain what #define COL_WIDTH 80, char filename[MAX_PATH + 1] and char input_line[COL_WIDTH + 1] do, that'd be awesome!
@redfox814 am also a newbie but what @firedraco told you is true,you only readind and writing to it but you didn't printout anything like cout << //your stuff you want to print out // and to your question
1
2
3
#include iostream // is an header file from standard library //
#define col_width 80 // this is a constant you define and can be access globally //
# char filename [MAX_PATH + 1] //  this has to do with array and am a newbie not so good at array but was a constant and define globally (to me) // 

so that's all i understand bout it, hope it help. :)
Topic archived. No new replies allowed.