This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's
Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.
General Coding and Design =>
Calculator Programming
Author |
Message |
|
Darth Android DragonOS Dev Team
Bandwidth Hog
Joined: 31 May 2003 Posts: 2104
|
Posted: 22 Dec 2004 07:38:34 pm Post subject: |
|
|
heres the code:
Code: #include <iostream>
#include <iomanip>
int main()
{
double x;
cout << "Enter a number: " << endl;
cin >> x;
cout << "The number you entered is " << x << " and its double is " << x * 2 << "." << endl;
return 0;
}
heres the compiler output:
Quote: dandroid@localhost:~$ gcc C++/121604.cpp
C++/121604.cpp: In function `int main()':
C++/121604.cpp:8: error: `cout' undeclared (first use this function)
C++/121604.cpp:8: error: (Each undeclared identifier is reported only once for
each function it appears in.)
C++/121604.cpp:8: error: `endl' undeclared (first use this function)
C++/121604.cpp:9: error: `cin' undeclared (first use this function)
it looks like its not including the header file iostream correctly or at all.
here's my gcc version info:
Quote: dandroid@localhost:~$ gcc -v
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.4/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.4 (Debian 1:3.3.4-9)
any ideas/help? |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 23 Dec 2004 04:45:20 am Post subject: |
|
|
No file extensions?
Also, you might as well make main() void for such a simple program and when you're just going to return 0 anyway.
Last edited by Guest on 23 Dec 2004 04:46:39 am; edited 1 time in total |
|
Back to top |
|
|
alexrudd pm me if you read this
Bandwidth Hog
Joined: 06 Oct 2004 Posts: 2335
|
Posted: 23 Dec 2004 12:42:40 pm Post subject: |
|
|
How old is your compiler? I know older versions need you to use "#include <iostream.h>", the .h being necessary for some reason. Maybe check your documentation. |
|
Back to top |
|
|
Adm.Wiggin aka Tianon
Know-It-All
Joined: 02 Jun 2003 Posts: 1874
|
Posted: 23 Dec 2004 03:37:42 pm Post subject: |
|
|
necessary "for some reason"?!?!?! it's the most important part! there is a little file named "iostream.h", for a good reason. there is no file named "iostream". |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 23 Dec 2004 03:57:07 pm Post subject: |
|
|
Win32/MSDOS doesn't mind, Linux does.
Of course the compiler can check if you mean file or file.h, but I consider that to be a dumb feature for a compiler. |
|
Back to top |
|
|
JoeImp Enlightened
Active Member
Joined: 24 May 2003 Posts: 747
|
Posted: 23 Dec 2004 04:20:28 pm Post subject: |
|
|
The proper way to use iostream is:
#include <iostream>
using namespace std;
void main()
{
cout << "bla bla bla";
}
That is the correct, more accepted way. Of course, you can always put the .h on the end at not put the 'using namespace', but most people don't like that now-adays. Like if I post a program I made somewhere that includes iostream.h, people yell at me. Look it up on google
Imp |
|
Back to top |
|
|
alexrudd pm me if you read this
Bandwidth Hog
Joined: 06 Oct 2004 Posts: 2335
|
Posted: 23 Dec 2004 05:35:14 pm Post subject: |
|
|
Yes, I know it is necessary, but only for older compilers. I don't know why they changed it, so I said "for some reason."
Please excuse my ignorance, my C++ class is really basic and we use compilers that are 10 years out of date. |
|
Back to top |
|
|
JoeImp Enlightened
Active Member
Joined: 24 May 2003 Posts: 747
|
Posted: 23 Dec 2004 09:23:28 pm Post subject: |
|
|
I wasn't responding to anyone's posts, just saying what I know.
Imp |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 24 Dec 2004 12:54:07 pm Post subject: |
|
|
alexrudd wrote: Please excuse my ignorance, my C++ class is really basic and we use compilers that are 10 years out of date.
Only 10? That's recent. |
|
Back to top |
|
|
alexrudd pm me if you read this
Bandwidth Hog
Joined: 06 Oct 2004 Posts: 2335
|
Posted: 24 Dec 2004 03:11:29 pm Post subject: |
|
|
@Sir Robin - then why does it says "style of function definition now obsolete" when we make functions? :P
@Darth Android - Still having problems? Or have any of the many things we have said done anything? |
|
Back to top |
|
|
Arcane Wizard `semi-hippie`
Super Elite (Last Title)
Joined: 02 Jun 2003 Posts: 8993
|
Posted: 24 Dec 2004 04:54:24 pm Post subject: |
|
|
alexrudd wrote: @Sir Robin - then why does it says "style of function definition now obsolete" when we make functions?
Wouldn't only new compilers say old definitions are obsolete? |
|
Back to top |
|
|
|
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
»
Go to Registration page