go0gle and the letter C
- Login to post comments
Sat, 09/17/2011 - 08:45
as you know I started to programming in C and I said:Why not Share basic programs and the users could give me tips?
And my brain said "Ok".
And for that is this space.
WARNING!!!!!
I don´t want superb comments,
I just want some tips and observations.
switch exercise
a very simple one.
Hey You!
Start the fun and Install the fan made CHAPTER 6: MOON OF GOO
You should return 0 at the end.
Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.
I have a question about that, when I "return 0;" the program inmediatly finish and don´t give me time to analize the result, is this normal??
if this is normal I will keep using getch,for analizing results
also putting "Getch" at the end is a bad practice??
Hey You!
Start the fun and Install the fan made CHAPTER 6: MOON OF GOO
Generally, you should be running command-line programs from the command line, so you can see all the stuff you're printf()'ing. Then, you won't have to getch() at the end.
Oh, yeah, and getch() is compiler-specific, since it's not a C standard. It'd probably be a good idea to not use it, yes.
And return 0; just ends the function and tells the operating system how the program went. Generally, the OS disregards this entirely, and seems to me that your compiler is automatically tacking on a return 0 at the end anyway, but it's a good idea to put the return 0 at the end so you don't confuse yourself. It's int main() after all, not void main().
And if you want, you can still getch() right before the return 0;. The "return 0;" line is where the function exits. Anything after it will be skipped, yes.
IRC | Chapter Tutorial | Reference Guide
Oh, yeah, and getch() is compiler-specific, since it's not a C standard. It'd probably be a good idea to not use it, yes.
And if you want, you can still getch() right before the return 0;. The "return 0;" line is where the function exits. Anything after it will be skipped, yes.
That´s all I need.Thanks MOM,(Tagged as usefull).
by the way i will post for tomorrow a program I made recently with simple functions that make conversions and a formula for distance,speed and time.
Hey You!
Start the fun and Install the fan made CHAPTER 6: MOON OF GOO
I made a small program once in C++ that converts Celsius to Fahrenheit and vice versa. I don't know where the code is, and I probably can't find it anymore, but I recommend to give it a go for good practice.
New GooFans Rules | My Addins
Program that get the speed,time and distance.And also Convert distance time and speed units.By choice and saving results
Took 6 hours
Hey You!
Start the fun and Install the fan made CHAPTER 6: MOON OF GOO
Si. I mean, whatever Spanish for "cool" is.
Just a few pointers and questions:
-Still using getch(), I see. Is it because you're not running the program from a command line, or what?
-What IDE are you using? Visual Studio? Code::Blocks? Borland (I thought that getch() was Borland-specific, but I could be mistaken. That was in 1993, after all)? getch() doesn't work in GCC, just so you know. You can replace it safely with getchar(); you'll just have to hit Enter after typing.
-Commenting your code is always a good idea, even if it's a small, simple program. The more comments in a program, the better. Start getting in a habit of at least commenting every block (Like every switch case statement or something). In complex code that I write, I comment practically every line. And I never regret it.
-By the way, "system("cls");" doesn't work in Linux. Stinking DOS/Unix command differences...
But overall, very nice. And a good amount of code, too. I can tell you're doing more and more complex stuff here (Though admittedly my Spanish is a bit rusty, so I can't tell exactly what you're doing 100% of the time).
Oh, and for the record, always watch for division by 0 when writing a program:
Didn't crash here, but in a lot of cases it will.
EDIT: Oooh, ooh, and add a feature to convert cubic light years into cubic angstroms. My friend did that once; it was fun.
IRC | Chapter Tutorial | Reference Guide
Use this:
It clears the screen on ANY operating system.
Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.
0_0 Third time i think goofans community help me very massive!
I didn´t got the "0" value as a option, I will be in that , and also i´m using
"Dev C++"IDE.
I´m contempling to do more global functions for a better run in other ambientations like linux.
Thanks!
Tomorrow New one!
Hey You!
Start the fun and Install the fan made CHAPTER 6: MOON OF GOO
The proper term is "Operating System", not "ambientation".
Hmm, strange that Dev-C++ allows that, since it uses GCC by default. Did you configure it to use some other compiler than GCC? If you dunno, that's fine.
By the way, development is halted on Dev-C++. Code::Blocks is a lot like it, only more up to date. Just so you know.
Anyhow, happy programming! Remember that the best language is LOVE.
-MOM
IRC | Chapter Tutorial | Reference Guide
It was a metaphor.
Hey You!
Start the fun and Install the fan made CHAPTER 6: MOON OF GOO
The metaphor would be better if it was a real word.
IRC | Chapter Tutorial | Reference Guide
Sure it is. Here's WordWeb's definition:
Word not found: ambientation
Look on the web
New GooFans Rules | My Addins
I personally use the MinGW compiler, which is just like GCC for Windows except it doesn't put any restrictions on what you can compile with it.
Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.
I use Code::Blocks which compiles via MinGW. It has options in the Project Properties to specify what platforms to allow building for.
I tweet like a bird
I have a lame website
Ok, perfect people:
Ambience!
Good?
I will search for Code Blocks.
Hey You!
Start the fun and Install the fan made CHAPTER 6: MOON OF GOO
And regular GCC does? I'm confused. I thought that GCC and MinGW were essentially identical.
@G0o-gle: Still no clue what you're talking about. How is an operating system ambient?
And yah, Code::Blocks is good. Just make sure that you download the version with MinGW included. Otherwise you won't be able to compile anything (Unless you have MinGW already installed, which come to think of it, you might since I think Dev-C++ comes with MinGW by default. I guess just try the regular download and if it doesn't work, download the MinGW version).
IRC | Chapter Tutorial | Reference Guide
Some versions of GCC say in the license that anything you compile needs to be LGPL. Others make it so that you need to have a GCC DLL on your computer. The cygwin one does that, for example: if you install Cygwin without GCC, you can't run a Cygwin-GCC-compiled EXE.
Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.
Hmm, interesting. Learn something new every day.
IRC | Chapter Tutorial | Reference Guide
@G0o-gle: Still no clue what you're talking about. How is an operating system ambient?
Forget it.
My attempt to make a demonstration of functions failed.I will try it... one more time!
Hey You!
Start the fun and Install the fan made CHAPTER 6: MOON OF GOO