This is our first video lecture. One thing
i have to clear knowledge of c and c++ is
not required to learn java. Today i will discuss
why c and c++ is platform dependent. First
thing which comes on mind is what is platform?
A platform is an underlying computer system.
On which the computer's application programs
runs. It is generally a particular computer
operating systems like windows, unix, machintose.
Suppose we are writing a c program with the
name x.c this means x.c file contains source
code. When we compile this program we get
x.obj file that contains machine language
code. Which is just equal to the source code
in x.c file. For example this x.obj file contains
the first statement to include a header file
like  when we run the program. c
compiler goes to the c standard library it
is generally found in tc\bin and searches
for the header file  there. When
the header file is found c compiler copy the
entire code this code will be in machine language
format from the header file into c program.
So if you write a c program of 10 lines and
the  file contains 200 lines then
the total size of the file will be 210 lines
this file is also called x.exe file. This
is a full- fledged file that contains the
entire program in machine language instructions.
These instructions are understandable to the
microprocessor. So it executes them and gives
the results. There are several microprocessors
developed by many companies, for example,
Intel Corporation. Every microprocessor can
recognize a group of instructions called the
Instruction set of that microprocessor. So
the instructions recognized by Pentium processor
may not be understandable to the Celeron and
similarly the instructions of Celeron may
not be understandable by Spark processor.
If we generate x.exe file on a computer with
Pentium processor, then that x.exe file contains
machine language instructions understandable
to Pentium only. If we try to execute this
x.exe file on another computer with Spark
processor, it may not be able to execute the
instructions of x.exe file. The reason is
Spark processor cannot understand the Pentium
processor instructions, which are in x.exe.
Similarly, develop x.exe file using an operating
system like DOS. Then copy this x.exe into
other operating system like UNIX. Now, try
to execute the x.exe file on UNIX. You will
see that you cannot the reason for this is
that every operating system stores the data
and instructions in different formats. For
example, the instruction for addition of two
values may be stored by DOS as: add a, b;
Whereas the same instruction may be stored
by UNIX as: a add b. So, if we try to execute
add a, b instruction in UNIX , it cannot understand
it since its format is different from what
it is expecting. This is the reason, why we
cannot execute the same x.exe file in different
operating systems.
