Variables

What is are variables in C/C++ ? A variable is a name given to a particular “memory location” in computer’s memory. Can you explain a bit more ? Alright, for example: In the above program, statement at line# 3 is a request to the computer asking “to allocate some space […]

strcpy vs memcpy

strcpy() and memcpy() lives in same header file (string.h in C and cstring in C++) and has similar purpose in their lives – “to create copies”. But they are different in the way they work. strcpy(): copies the string at src, including its terminating ‘\0’, to the memory at dest will only work […]

Qualifiers – const

const: It is a promise by the programmer to the compiler, saying that “I won’t change the value of this variable, after I initialize it” If the promise is break then, the compiler won’t compile the program. The below code will compile and works, even though it is changing the […]

Modifying Data Types

Modifying data types means: Increasing or decreasing the default range of the data type, basically requesting compiler to allocate more or less memory than the default memory of the data type. what to do with the left most significant bit – use to store positive or negative sign ? or […]

Data Types

Data Type: Defines the type of data that the associated variable can store. Defines the type of operations that can be performed on the associated variable (or on actual data). Defines the size of memory to be allocated by the compiler. Properties of Data Types: Size: Memory – i.e., no. […]

C/C++ Compilation

Both C and C++ are compiled languages – which means the source code (program) written in C/C++ needs to be “compiled” before it can be executed (run). C/C++ programs can be compiled to create either of the following forms: Executable (usually called “binary file”) Shared library Static library what is […]

How to read a string with space using “scanf()”

scanf() is a general purpose console input routine. To read a string “%s” format specifier is used. scanf() reads a string until the first “white space” character is encountered. below is the list of “white space” characters: space tab (t) vertical tab (v) form feed (f) Example 1: Output:                                                    The […]

First Program

C Program C++ Program Both programs looks pretty much similar isn’t it ? but, there are some differences to note and understand. Similarities: #include : This is a Preprocessor directive, instructs the C/C++ compiler to “include some other file/code into current file/code, usually used to include header files” (stdio.h for […]

Overview of C/C++

C was developed by Dennis Ricthie on a DEC PDP-11 machine, which was running on UNIX Operating System. Now, there can be a question pop up in your mind, “I heard UNIX was written in C, how come C was developed on UNIX ?” answer is “Yes, you are correct” […]