Problem with else/if and UNtidy program
Hi
A few days playing with c++. I,m having trouble with else if, And a few queries with my program, If any 1 can help with. The program runs and dose what I want Code:
#include <iostream> |
see man ifstream: http://www.cplusplus.com/reference/i...ream/ifstream/
the line: if (MyFile) has no meaning, it will not do what you expect. |
Quote:
|
Quote:
Code:
if (condition1) |
Hi
The 1st program works ok (there is a problem, It puts a ? in a diamond on the command line). But I would like to know where I,m wrong on the 2nd program. I have googled but all i can find are using cout to output something, not open a Doc. I know this is all beginner stuff but thats what I am, dwhitney67 I have tried to put in to practice from your last post but cant seem to make it work. Code:
#include <iostream> Code:
#include <iostream> |
Quote:
As for the second program, your braces are still a mess. You should learn to keep your indentation consistent troughout your code. Then it will be easier for you to spot the errors in your syntax. Code:
{ Code:
} else if( Answer == '2' ) if you have something like: Code:
if(a) Code:
if(a) { Code:
if(a) { |
Hi
Ok I have tried looking up indenting the code and that shows various examples, they basically say keep it all the same uniformed Code:
#include <iostream> I also hope that the Layout is better |
My first question... what editor are you using? Your perception of good indentation is not evident after you posted your code. Did you review the code you posted? The indentation is crap.
Look at this: Code:
#include <iostream> |
Ok
I realise this is alot harder than I thought, I picked up on doing this a week ago as a pure past time. I googled and picked up on a few tutorials which work, I thought I could expand on them. (Experimental) Not realiseing things don't quite work as expected. I did know there would be alot of studying I,m not trying to rewrite an OS just keep myself amused I am using vim as the editor |
All times are GMT -5. The time now is 12:06 AM. |