A Digital Age Deserves A Digital Leader

Need some Visual C++ Express help. AND some C++ help.

Need some Visual C++ Express help. AND some C++ help.

Postby xxsonyboy4lfexx » Thu Oct 04, 2007 6:55 pm

At school we were learning come C++ but with the old Visual 6 or something and from some old book. Can someone tell me how to properly setup a program using Visual C++ express? And in my code its iostream.h. But I heard the .h is out dated and dont know what to change it to. And I cant even excute this in Visual. And this is in a Source.cpp.
Code: Select all
#include <iostream>

main()
{
   int number_of_people;
   int share;
   int remainder;

   cout << "How many people are there?";
   cin >> number_of_people;
   
   share= number_of_people / 50;
   cout << "You need this many buses " << share << '\n';
   remainder= number_of_people % 50;
   cout << "You have this many people left over " << remainder << '\n';
   return 0;
}
Image
PRO Level 8
User avatar
Posts: 315
Joined: Sat Jan 07, 2006 4:42 pm
Location: California

Postby NoReflex » Thu Oct 04, 2007 7:49 pm

I'm not sure of this because I haven't worked with VisualC++ but I think that you must import conio.h to use the cin and cout functions. If the extension .h doesn't work you can try to import .c files (iostream.c and conio.c) - I could be wrong but I think the imports should look like this :
Code: Select all
#include <conio>
#include <iostream>

Good luck!

Best wishes,
John!
PRO Level 10
User avatar
Posts: 431
Joined: Wed Nov 17, 2004 8:41 pm
Location: Romania

Postby xxsonyboy4lfexx » Thu Oct 04, 2007 8:33 pm

This is my same error. With conio or iostream. Am I setting it up incorrectly? Like saving it?

Image
Image
PRO Level 8
User avatar
Posts: 315
Joined: Sat Jan 07, 2006 4:42 pm
Location: California

Postby NoReflex » Thu Oct 04, 2007 8:43 pm

It looks like the executable file hasn't been created. Did you build your project or compile the source file(s)? Try to compile Source.cpp and look for eventual warning/error messages. Did you create a console or window project (not sure these are the names used in VC++)?
PRO Level 10
User avatar
Posts: 431
Joined: Wed Nov 17, 2004 8:41 pm
Location: Romania

Postby xxsonyboy4lfexx » Thu Oct 04, 2007 9:14 pm

I will make sure everything is built. Its a Win32 Console App
Image
PRO Level 8
User avatar
Posts: 315
Joined: Sat Jan 07, 2006 4:42 pm
Location: California

Postby xxsonyboy4lfexx » Thu Oct 04, 2007 9:17 pm

I don't see any compiles but I did all the builds that I could choose and I continue to get the same error.
Image
PRO Level 8
User avatar
Posts: 315
Joined: Sat Jan 07, 2006 4:42 pm
Location: California

Postby xxsonyboy4lfexx » Thu Oct 04, 2007 9:21 pm

I tried doing another new project and opening the source file a different way. And I get the same error but I also noticed this one when it failed the build

c:\documents and settings\andrew\desktop\andrew\files\coding\test\test\test.cpp(1) : fatal error C1083: Cannot open include file: 'conio': No such file or directory
Image
PRO Level 8
User avatar
Posts: 315
Joined: Sat Jan 07, 2006 4:42 pm
Location: California

Postby NoReflex » Fri Oct 05, 2007 11:06 am

That means it cannot find the library files for the functions you're using (cin, cout etc). This can appear if the compiling directories haven't been set (which means the compiler doesn't know where to look for iostream.h and conio.h)
You should check the Options (or Preferences menu) for the compiler directories. You should also search the files iostream.h and conio.h to see what is the location of those two on your computer.
PRO Level 10
User avatar
Posts: 431
Joined: Wed Nov 17, 2004 8:41 pm
Location: Romania

Return to HTML, CSS, and Scripts

Who is online

Users browsing this forum: No registered users and 4 guests

cron
cron