Just started C++. Problems with MS Visual C++ 2005 Express.

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2007
Posts: 4
Reputation: soultron is an unknown quantity at this point 
Solved Threads: 0
soultron soultron is offline Offline
Newbie Poster

Problem with <iostream.h> in MS Visual C++ 2005 Express.

 
0
  #1
Feb 25th, 2007
I'm totally new to programming, but have been getting by fine so far.

I'm taking a highschool programming class, and am trying to do some of my assignments from home.

We've been told to work with <iostream.h> for our input and output, but for some reason, I get an error when I try to compile my programs at home;

fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory

The thing is, my code builds without errors when I'm working at school!

I've tried moving the libraries around so that Visual C++ can locate it, but nothing has worked so far.

I really want to start working with <stdio.h> and printf() but I don't think my teacher would accept the work, since he's hellbent on getting us to code with older techniques. (Seems like the lines we're writing aren't very "hip" anymore, since everywhere I look outputs are accomplished with printf() and such.)

Sorry if it was a stupid question. I'll try fiddling some more while I wait for responses.
Last edited by soultron; Feb 25th, 2007 at 1:34 am. Reason: Changed title to be more specific.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,580
Reputation: Infarction has a spectacular aura about Infarction has a spectacular aura about Infarction has a spectacular aura about 
Solved Threads: 52
Infarction's Avatar
Infarction Infarction is offline Offline
Battle Programmer

Re: Problem with <iostream.h> in MS Visual C++ 2005 Express.

 
0
  #2
Feb 25th, 2007
<iostream.h> is a deprecated header, and was never part of standard C++. I'm assuming you're using VC++6.0 or a similarly older version of Borland. The standard header is <iostream> so you may have to change it between school and home. You may consider raising the issue with your teacher, but there's a chance that he doesn't care, or may even get mad at you.

Originally Posted by soultron View Post
I really want to start working with <stdio.h> and printf() but I don't think my teacher would accept the work, since he's hellbent on getting us to code with older techniques. (Seems like the lines we're writing aren't very "hip" anymore, since everywhere I look outputs are accomplished with printf() and such.)
printf() is the C way of managing output, and it's much older than C++ output using cout.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Just started C++. Problems with MS Visual C++ 2005 Express.

 
0
  #3
Feb 25th, 2007
> We've been told to work with <iostream.h> for our input and output

Your compiler probably doesn't support it because that header is old and outdated. Try using the Standard Template Library; it's up-to-date and you'll notice the headers don't have a file extension:
  1. #include <iostream>
  2. using namespace std;
> I really want to start working with <stdio.h> and printf()
You're confusing C and C++. stdio.h and printf() are actually C functions. For now, stick with the C++ and the standard template library.

> but I don't think my teacher would accept the work
There is nothing incorrect about using modern coding methods, nor is there any reason why you should revert to outdated libraries. The snippet I showed you above is correct; using iostream.h is not. If he disapproves of it, show him this link.

> since everywhere I look outputs are accomplished with printf() and such.
Actually C++ was invented after C, so printf() and scanf() are actually older than cin and cout. Both languages have their advantages and disadvantages, and although you can mix them, it's generally not a good idea unless you know what you're doing.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 4
Reputation: soultron is an unknown quantity at this point 
Solved Threads: 0
soultron soultron is offline Offline
Newbie Poster

Re: Problem with <iostream.h> in MS Visual C++ 2005 Express.

 
0
  #4
Feb 25th, 2007
Thanks much! I did try using <iostream>, but now I'm getting errors on lines when I use cout, cin and endl; statements. Hah!

EDIT: Thanks joeprogrammer. Your snippet has my program working! I'll be sure to pass on that link to my teacher. Whether or not he'll take to it, I'm not sure. He admitted to not programming in C++ for several years now, and being comfortable with older languages like FORTRAN.

I'm guessing the textbook (published in 1997 ... ) isn't really up to date with the standards of Vis 2005.

Thanks for the help. I'll just have to fiddle with my code in order for it to make the jump from school to home. There's a translation that needs to occur, I just need to find out how to do it. I just hope the work I'm doing now will be useful to my studies in University next year, especially if we're working with a decade-old text!
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Just started C++. Problems with MS Visual C++ 2005 Express.

 
0
  #5
Feb 25th, 2007
be sure to use the correct namespace when addresses those methods.
They're in the std namespace (and have been for the last 10 years or so, so since just after your book was published).
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC