I'm going to try those tips. I wrote the program in gedit and compiled it with gcc via command line and when I ran it, it didn't 'end' correctly.
but I was proud of it non the less :)
We are the best invite forum on the internet! Here you will find free invites, free seedboxes, free bonuses, and much more. Our members know the true meaning of sharing and have created a truly global bittorent community! Our site has the most up to date information on all private trackers and our members will guide you and introduce you to this truly secretive and enlightened club. Ready to get started? Register now!
I'm going to try those tips. I wrote the program in gedit and compiled it with gcc via command line and when I ran it, it didn't 'end' correctly.
but I was proud of it non the less :)
hmm. Perhaps you forgot to return 0 at the end? Normally not ending correctly means it returned other than 0, i.e. error.
@Sever, actually I just looked at the program again, the system("pause") command will not work in Linux. And even in Windows, it's probably best to avoid it, since it is heavy on resources and not portable to other operating systems.
There's a variety of things you can use instead. For this program, since you are running it from the command line, you can just delete that whole line, since it doesn't really do anything important. So for the first program you can write this:
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
If you do want your system to pause, here is an alternative you can use:
Things to Avoid in C/C++ -- system("pause"), Part 4 - GIDNetwork
By the way, since you are now using return 0, in Linux to check how your last command executed type
echo $?
This will show you the return value of the last executed command. By default, the return value of 0 means the command executed correctly. When you start writing bigger programs, you can define your own return values for various errors, and then you will know what caused the error.
Afaik, there is no "pause" command in linux. You can use getchar() instead, it should work for both windows and linux.
I decided to learn this language. I found some good example programming tasks for beginners on a school's website. Unfortunately I can't get along with them, though I heard that they are really easy. If anyone has some time to help me by writing some code with detailed comments /so I would have a better view about functions and what do they do/ please pm me. I woul really appreciate that. :)
I agree with what you said about using int main() but better still to write int main(void) if you're not using command line args I think, or else specify them.
I started learning C in computer architecture. I had no experience with C prior to that class and our first program was like this. Our final program was to create an LC-3 assembler. I still have nightmares from that class. Can't wait to see some of your advanced tutorials.
are there more tutorials on this subject, c++? I would be greatly interested. Me and a buddy of mine. It seems to have stopped at tutorial one
Yay, the good old Hello world at its best :)
I love the style of this tutorial, as it goes very much into detail and is great for beginners to get a grip on the concept of programming in general.
I think C is a good language to start with as its basics are relatively easy to learn but later on the language can be used for very complex programstructures aswell.
So you picked a good way to visualize this topic and I enjoyed reading it although I know this program in and out already by now :D
Good Work!
zealot