Click to See Complete Forum and Search --> : Any one know C?
retoon
12-03-2002, 10:46 AM
Hey, if someone could tell me why my code is not compiling correctly, I would be most obliged. This application is simply a mathematical function.
--
#include <iostream>
//Iostream.h doesn;t work either
{
int main;
std::cout << "\nAny number from 1 to 5";
std::cin >> onetfive;
std::cout << "\nAny number from 1 to 100";
std::cin >> onethundred;
std::cout << (onetfive*onethundred);
return 0;
}
__
Problably some incredibly stupid mistake, but there is no rush on this, not like its that important. Any way, I would apreciate any help recieved.
Rüpel
12-03-2002, 10:56 AM
#include <iostream>
int main()
{
std::cout << "\nAny number from 1 to 5";
std::cin >> onetfive;
std::cout << "\nAny number from 1 to 100";
std::cin >> onethundred;
std::cout << (onetfive*onethundred);
return 0;
}
btw: this is C++ not C ;)
truls
12-03-2002, 10:58 AM
This should work though:
#include <iostream>
int main()
{
int main;
int onetfive, onethundred;
std::cout << "\nAny number from 1 to 5: ";
std::cin >> onetfive;
std::cout << "\nAny number from 1 to 100: ";
std::cin >> onethundred;
std::cout << (onetfive*onethundred);
return 0;
}
retoon
12-03-2002, 11:15 AM
Sorry Rupel, I mean't to say c++, I just am one of those people who make the mistake of calling c++ c for matters of lazyness. I will stop that. Truls, thank you kindly, i now see that I forgot to declare my variables. As I forsaw, a stupid mistake!
majidpics
12-04-2002, 08:36 PM
just add it "main()"
retoon
12-06-2002, 01:47 AM
Hey, I tried putting that code together, and it still gave me an error. This is what it is.
--
No new line at end of input
--
I use RH8, and I have been opening the terminal, and typing "make mycode". Where mycode is the name of the source. I am not sure if I should be typing cc mycode, or what, but I figured make was the way to go.
GotAnyGrapes?
12-06-2002, 02:44 AM
To compile your source code, open a terminal, browse to the directory containing the source file and type:
g++ -o hello hello.cpp
where "hello" is the name you want your executable to have, and "hello.cpp" is the name of your source file. To run the exectuable type:
./hello
The code listed by truls compiles and runs on my computer (RH 8, g++3.2).
(make uses a Makefile to determine what sources need to be updated, and then calls commands listed in the Makefile. I think make is a bit much here, since there is only one source file.)
bjornredemption
12-06-2002, 03:24 AM
Since the topic of compiling came up how would i
compile a java program ? I got gcc-java installed
whats the compile commmand???
gjava????? something?
bwkaz
12-06-2002, 11:22 AM
This is personal opinion land, but personally, I wouldn't go with gcc-java. I'd grab the JDK 1.4.1 (or whatever is the latest) from Sun's site, and install that, then use the javac compiler in that package.
I have an impression of gcc-java that says it doesn't work right -- but that could be entirely false, I haven't looked at recent versions. I believe the compiler is named gcj if you want to use it -- you could just open a terminal, type a g, and hit tab once or twice, to see all installed commands that start with g. The java compiler should be among those, but the list might be a bit long.
bjornredemption
12-06-2002, 04:30 PM
Thanks i think i'll give that a go
shadowrider
12-07-2002, 06:43 AM
Originally posted by retoon
Hey, I tried putting that code together, and it still gave me an error. This is what it is.
--
No new line at end of input
--
I use RH8, and I have been opening the terminal, and typing "make mycode". Where mycode is the name of the source. I am not sure if I should be typing cc mycode, or what, but I figured make was the way to go. think if you have "no new line....", you would just press enter and save it, and see what happens