Archived

This topic is now archived and is closed to further replies.

ApparitionX

???DJGPP with XP???

Recommended Posts

ApparitionX    122
I have an xp comp and djgpp doesnt work for me. I have everything working great till I click make and it tells me that just about everything is undeclared when it debugs. What does that mean? Ive checked the program a few times and im pretty sure it is correct now. Ive gotten it out of a book called weekened crash course which I think is a good beggining book but not my last book of course for C++. Have any of you had this problem... and if so how do I fix it? Should I just find another similar compiler. Which ones out there are similar to djgpp? I like djgpp because it reminds me of qbasic which was pretty simple.

Share this post


Link to post
Share on other sites
ApparitionX    122
still have the undeclared error in Dev-C++ plus one othe error.

Here is the programming code whats wrong with it?
//
// Conversion - convert temperature from Celsius
// degree units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212 - 32)/100 + 32
//
#include <stdio.h>
#include <iostream.h>
int main(int nNumberofArgs, char* pszArgs[])
{
// enter the temperature in Celsius
int nCelsius;
cout << "Enter the temperature in Celsius:";
cin >> nCelsius;

// calculate conversion factor for Celsius
// to Fahrenheit
int nFactor;
nFactor = 212 - 32;

// use conversion factor to convert Celsius
// into Fahrenheit values
int nFahrenheit;
nFahrenheit = nFactor * nCelsius/100 + 32;

// output the results
cout << "Fahrenheit value is:";
cout << nFahrenheit;

return 0;
}

Share this post


Link to post
Share on other sites
ApparitionX    122
um i just started learning about programming and what i do is i compile it and it says

C:\wecc\programs\Conversion.cpp
[Warning] In function `int main(int, char**)':

10 C:\wecc\programs\Conversion.cpp
`cout' undeclared (first use this function)

10 C:\wecc\programs\Conversion.cpp
(Each undeclared identifier is reported

11 C:\wecc\programs\Conversion.cpp
`cin' undeclared (first use this function)

16 C:\wecc\programs\Conversion.cpp
`nfactor' undeclared (first use this

21 C:\wecc\programs\Conversion.cpp
`nFactor' undeclared (first use this

Im guessing that I didnt have a problem with djgpp after all because this basicly the same errors

[edited by - ApparitionX on March 18, 2003 2:52:45 PM]

Share this post


Link to post
Share on other sites
ApparitionX    122
I figured it out int has to go after cout and cin!!!!!!!!!!!!! yes!!!! This is so confuseing that only got rid of one error. this makes no sense there shouldnt have even been a problem there....


[edited by - ApparitionX on March 18, 2003 3:00:31 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
It seems like you might be invoking a pure C compiler instead of a C++ compiler. This would explain why cout and cin are undefined. Also, in C, your variable declarations must be the first statements in a function. That would explain the nFactor undefined error. At least that is one possibility

Share this post


Link to post
Share on other sites
Null and Void    1088
Dev C++ includes a pure C compiler and a C++ compiler.

The header iostream.h has never been standard. You should use iostream instead. The objects cout and cin are not in the global namespace, they are in the std namespace.

Your variable nFahrenheit is going to store a integer truncated value, if you're unsure of why the math is skewed.

There is no reason to include stdio.h (and, if there were, cstdio would be preferable in C++).

If you're interested, I mangled your code into a usable state:

  
#include <iostream>


using std::cout;
using std::cin;
using std::endl;

int main(int argc, char *argv[]) {
double Celsius, Fahrenheit;

cout << "Enter the temperature in Celsius: ";
cin >> Celsius;

Fahrenheit = (9.0/5.0)*Celsius + 32.0;

cout << "Fahrenheit value is: " << Fahrenheit << endl;

return 0;
}



Edit: fixed spelling error .



[edited by - Null and Void on March 18, 2003 6:21:41 PM]

Share this post


Link to post
Share on other sites
afterburn    124
quote:
Original post by Anonymous Poster
Also, in C, your variable declarations must be the first statements in a function. That would explain the nFactor undefined error. At least that is one possibility


That is not true. Cause you define them within scope.
Meaning I can do this.

void Init(int x){
int c;
{
int x;
}
cout << x;
}

Would give a compile error because the int x is inside of a "{" and "}" these define scope just as you can use them to define a variable in a loop for creation. This way you can insure that all information in the variable is not old data.

The cout is not being define because you have not included the library.

Share this post


Link to post
Share on other sites