Ok, this is my second try at C++. My first was a test, submitted by one of your board members, that produced the desired results "hello world!", it worked, I had fun, now I want to move on to step one.Code:#include <iostream.h>
#include <fstream.h>
#include <string.h>
struct qtype {
char board [80];
char title [80];
char body [80];
};
void getboard {(qtype item);
ifstream sourcefile ("board.txt");
if (sourcefile.fail())
cerr << "Error opening board.txt...";
else
(while ! sourcefile.eof());
strcpy (item.board);
sourcefile.close();
return;
};
void gettitle {(qtype item);
ifstream sourcefile ("title.txt");
if (sourcefile.fail())
cerr << "Error opening title.txt...";
else
(while ! sourcefile.eof());
strcpy (item.title);
sourcefile.close();
return;
};
void getbody {(qtype item);
ifstream sourcefile ("body.txt");
if (sourcefile.fail())
cerr << "Error opening body.txt...";
else
(while ! sourcefile.eof());
strcpy (item.body);
sourcefile.close();
return;
};
void output {
cout << board << endl;
cout << title << endl;
cout << body << endl;
};
If you would like to reveiw my goal with this program, how it applies to forums such as this one and FAQ's, see my "Forums Autoresponder" post.
The goal with this first step is to load 3 strings, an address, a title, and a body, and then output them to the screen. This is simple enough. Output should look like this
board
title
post
if "board.txt" contained "board"
etc....
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I get an error at line 11, and do not know if that is
void getboard {(qtype item);
or
if (sourcefile.fail())
to rephrase that question, does the line number include empty lines?
Will this program work for the above goals, and how do I fix it to do so? I think removing the extra { will work
The next step would be to add the variables for multiple results.
board
title
post
board2
title2
post2
board3
title3
post3
if "board.txt" contained "board,board2,board3"
etc...
And lastly, Im using a java compiler to test my program out because I do not know how to compile it with the digatilmars C++ compiler I have. Seems kinda stupid, I know, but how do I compile this on my computer, instead of online?