Project Builder....

Mac Osxtopus

Registered
Im learning C++ from a book that addresses the ANCI ++ Standard(or something like that). Ive been trying to compile this program a while now and i cant find the problem. Here is the program: oops! i forgot this forum doesnt take gt's or lt's.
#include iostream //normal header files..
#include stdio.h
#include stdlib.h
using namespace std;

char name[10][80]; // where names are stored
char email[10][80]; // email adresses..
float rating[10][80]; // your rating of the person...

int menu();
void enterinfo(), report();

int main()
{
int choice;
cout << "Make a Decision: \n\n";
do {
choice = menu();
switch(choice) {// options...
case 0:
break;
case 1:
enterinfo();
break;
case 2:
return 0;
break;
default:
cout << "Invalid Input";
}
} while(choice!=0);
return 0;
}

int menu()
{
int choice;// the menu.... return the choice once its made.
cout << "1: Enter Information, then view it\n";
cout << "2: Quit";
cin >> choice;
return choice;
}

void enterinfo()
{
int i;
for(i=0; i<10; i++)
{
cout << "Enter The person's name here:\n";// this is where i get most of the errors....
cin >> name;
cout << "Now enter the person's e-mail:\n";
cin >> email;
cout << "Now, what is your rating(in a decimal number) of this person?";
cin >> rating;
cout << "This is what you have input into the program: \n";
report();
}

}

void report()
{

cout << "Name = " << name << '\n';
cout << "e-mail = " << email << '\n';
cout << "and finally, your rating of this person is:\n";
cout << rating[j] << '\n';
}

When i syntax check/build and run it gets errors in the HEADER FILES!! And i cant seem to get this fixed. All i simply want this to do is to store the information listed in these different arrays and then display them. Any help would be appreciated
 

Ghoser777

Registered
Your first problem is that you didn't put alligators around your header files... although that maybe vB. The other problem is that iostream is missing it's .h extension.

After fixing those problems, it got further, but many more errors that you should be able to deal with.

HTH,
Matt Fahrenbacher
 

Captain Code

Moderator
Staff member
Mod
You don't need the angle brackets if you have the header file in quotes like #include "iostream.h".

In ANCI C++ you can do
Code:
#include &#8249;iostream&#8250;
I'm not sure if that will fix all of your problems, but you should also put the other header files in quotes.
 

jonasbay

Registered
There could also be a problem with the compatibility, because iostream is a C++-headerfile and stdio.h is a C-headerfile. I remeber having such problems with VisualC++, don't know how it is with ProjectBuilder.
 

bwanabob

Timelord
The include lines need brackets. eg: #include <iostream>

You will have problems in the report() function. Undefined variables i, and j.
 

Pawn Trader

Registered
Originally posted by jonasbay
There could also be a problem with the compatibility, because iostream is a C++-headerfile and stdio.h is a C-headerfile. I remeber having such problems with VisualC++, don't know how it is with ProjectBuilder.
Thank you, thank you, thank you!

None of the documentation or tutorials I've come across mentioned that fact. It never even occured to me to wonder about that. I assume C and C++ header (and library?) files can't be used in the same project?
 

Pawn Trader

Registered
Originally posted by jonasbay
is this a joke or serious ?
What, my response? That was totally serious. That little detail is something I hadn't run across (or at least hadn't noticed) in my studies so far.
 

vertigo

Swollen Member
Originally posted by jonasbay
There could also be a problem with the compatibility, because iostream is a C++-headerfile and stdio.h is a C-headerfile. I remeber having such problems with VisualC++, don't know how it is with ProjectBuilder.
This is not a problem. At least if you're using a C++ compiler it's not.
 

Mac Osxtopus

Registered
Well i didnt know what to choose......... im still learning C++, as you can see.
When using Pbuilder my project was a C++ Tool (that was the only way i could do build and run to test my projects as i learned C++. Once i learn C++, what project type should i choose? (and no, im not even thinking of carbon after i learn C++).

I recently got a Codewarrior Lite CD and i am using it for C, and it supposedly works for C++, so ill try it out.
 
Top