![]() |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
Quote:
But I agree with conio.h and getc() being old ms-dos legacy. What about getchar()? Also only needs stdio.h, but I'm not sure about the buffered/unbuffered input issue. |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
1 Attachment(s)
i got this
#include <stdio.h> main() { for( ;; ) { printf ("Hello World!\n"); } } but this is for loop and works on pc and when i try to run this on n900 like in my first post.. this time nothing happened and put me back to Mydocs it shows nothing! |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
Quote:
Code:
# include <stdio.h> g++ hello.cpp and runs with... ./a.out where a.out is the default name for executables created with gcc/g++, if you don't specifiy a different output file with -o, e.g. g++ -o myprogram hello.cpp |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
there is no error now but it does not execute also(i think problem is related to device now not in programme)
BTW thanks to all you guys for so quick reply |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
Quote:
copy it to /home/user f.ex., then use chmod +x. |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
It looks like you're writing just plain C anyway.
I've just written my first ever bit of C++ code so don't laugh ;) Code:
#include <iostream> |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
for c++ try this
#include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } this will give you the "hello world" with confirmation of correct operation and ask for keyboard input to finish (return 0 to main) iostream is required for input/output functions printf is the "C" equivalent cout when using "C++" |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
@nicholes
Just to reiterate: your initial code is mostly C, not C++. To write C++, use the correct libraries (iostream in this case) and C++ functions e.g. std::cout in place of printf. I might do things slightly differntly to the above two suggestions... re: Captwheeto's code
re: onethreealpha' code
Code:
#include <iostream> // use correct i.e. C++ library http://www.acceleratedcpp.com/ You might think it's a bit old but it's really good for the basics, especially using the standard template library. |
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
Quote:
|
Re: (.cpp)"Hello world" in n900 (getting error) plz guide me.
I assume you are trying DOS/WIndows based c++ example.
Please note that getch does not exist in gnu linux. As someone pointed out, you need to use getchar, but prior to that you have to modify the terminal settings (from within code). The functioning of getchar depends on terminal settings in order to emulate getch. By default it returns no matter what/if the key was pressed. See the manual termios.h and tcgetattr. |
All times are GMT. The time now is 06:29. |
vBulletin® Version 3.8.8