Freelancer

Some important questions for beginners

Some important questions for beginners for C program learners

Ques 
If I want to give someone a program I wrote, which files do I need to give him?
Ans 
C programming example
One of the nice things about C is that it is a compiled language. This means that after the source code is compiled, you have an executable program. This executable program is a stand-alone program. If you wanted to give hello to all your friends with computers, you could. All you need to give them is the executable program, hello.exe. They don’t need the source file, hello.c, or the object file, hello.obj. They don’t need to own a C compiler, either. Your friends or those people you give the executable will need to be using the same type of machine as you—such as an PC, a Macintosh, Linux machine, etc.



Ques 
After I create an executable file, do I need to keep the source file (.c) or object file (.obj)?
Ans 
If you get rid of the source file, you have no way to make changes to the program in the future, so you should keep this file. The object files are a different matter. There are reasons to keep object files, but they are beyond the scope of what you’re doing now. For now, you can get rid of your object files once you have your executable file. If you need the object file, you can recompile the source file. Most integrated development environments create files in addition to the source file (.c), the object file (.obj or .o), and the executable file. As long as you keep the source file (.c), you can always re-create the other files. 


Ques
If my compiler came with an editor, do I have to use it?
Ans
Definitely not. You can use any editor, as long as it saves the source code in text format. If the compiler came with an editor, you should try to use it. If you like a different editor better, use it. I use an editor that I purchased separately, even though all my compilers have their own editors. The editors that come with compilers are getting better. Some of them automatically format your C code. Others color-code different parts of your source file to make it easier to find errors.


Ques
What do I do if I only have a C++ compiler and not a C compiler?
Ans
C++ is a superset of C. This means that you can use a C++ compiler to compile C programs. Most people use Microsoft’s Visual C++ to compile their C programs on Windows and GNU’s compiler on Linux and UNIX. The compilers included with this book’s CD will compile both C and C++ programs.  

Ques 
Can I ignore warning messages?
Ans 
Some warning messages don’t affect how the program runs, and some do. If the compiler gives you a warning message, it’s a signal that something isn’t right. Most compilers let you set the warning level. By setting the warning level, you can get only the most serious warnings, or you can get all the warnings, including the most minute. Some compilers even offer various levels in-between. In your programs, you should look at each warning and make a determination. It’s always best to try to write all your programs with absolutely no warnings or errors. (With an error, your compiler won’t create the executable file.)

No comments

Powered by Blogger.