Saturday, October 5, 2013
What is a transposition cipher method?
Posted by
Sunflower
at
10/05/2013 08:26:00 PM
0
comments
Labels: Characters, Cipher, Communication, Cryptography, Decoding, Encoding, Encryption, Functions, Implementations, Message, Methods, Protection, Secure, Security, Text, Transposition Cipher Method
![]() | Subscribe by Email |
|
Sunday, June 30, 2013
Explain the single and two level directory structures
Posted by
Sunflower
at
6/30/2013 12:30:00 PM
0
comments
Labels: Characters, device, Directory, File system, files, Individual, Limitations, Location, Logical, Operating System, Physical, Single-level, Standard, String, Structure, System, Two-level, Users
![]() | Subscribe by Email |
|
Wednesday, May 30, 2012
Explain the concepts of URL manipulation?
Components of URL
- The scheme name which is usually a protocol.
- The scheme is followed by a colon
- Two slashes
- Name of the domain (if any depending on the
scheme).
- A port number
- CGI (common gateway scripts) scripts
- Query string
- Fragment identifier (optional)
Categories of URL
What is meant by URL Manipulation?
What is URL Poisoning?
Posted by
Sunflower
at
5/30/2012 11:55:00 PM
0
comments
Labels: Categories, Characters, Components, Domain, files, Internet, Parameters, Protocol, Resources, Server, Strings, Technique, Uniform Resource Locator, URL, URL Manipulation, Web pages, Website
![]() | Subscribe by Email |
|
Monday, October 10, 2011
Some details about Multi dimensional arrays in C...
An array can be defined as the collection of variables of the same type that are referenced by a common name. Arrays are of two types namely one dimensional arrays and multi dimensional arrays. One dimensional array consists of finite homogenous elements whereas a multi dimensional array is composed of elements each of which is itself an array. Arrays refer to a named list of a finite number n of similar data elements. Each of the data elements can be referenced respectively by a set of consecutive numbers, usually 0, 1, 2, 3, 4,….., n. the simplest form of a multi dimensional array is the two dimensional array.
You can declare a two dimensional array as follows:
Type array name [ rows ] [ columns ];
Where type is the base data type of the array having name name, rows, the first index, refers to the number of rows in the array and columns, the second index refers to the number of columns in t5he array. For example:
Int sales [ 5 ] [ 10 ] ;
The general form of array initialization is shown below:
Type array name [ size N ] = { value list } ;
The value list is a comma separated list of array elements values. The element’s values in the value list must have the same data type as that of the base type of the array.
Int days [ 5 ] = { 1, 2, 3, 4, 5 } ;
Character arrays can also be initialized as shown below:
Char string [ 10 ] = { ‘c’ , ‘a’ , ‘t’ ‘\0’ } ;
Multi-dimensional arrays can also be initialized in the same way as simple dimensions one. For example:
Int abc [ 3 ] [ 2 ] = { 1, 1,
2, 2,
3, 3 } ;
This can be done it the other way also :
Int abc [ 3 ] [ 2 ] = { 1, 1, 2, 2, 3, 3 } ;
A multi dimensional array of strings can be initialized as shown below:
Type array name [ size N ] = { value list } ;
Here type declares the base type of the array, the array name specifies the name with which the array will be referenced and size defines how many elements the array will hold. The size must be an integer value or integer constant without any sign. The value list is a comma separated list of array’s elements values. The element values in the value list must have the same data type as that of the base type of the array.
Int days [ 5 ] = { 1, 2, 3, 4, 5 } ;
Character arrays can also be initialized as shown below:
Char string [ 10 ] = { ‘c’ , ‘a’ , ‘t’ , ‘s’ , ‘\0’ } ;
Multi dimensional arrays are also initialized in the same as the single dimensional one. For example:
Int cube [ 3 ] [ 2 ] = { 1, 1,
2, 2,
3, 3 } ;
This can be done in the other way also:
Int abc [ 3 ] [ 2 ] = { 1, 1, 2, 2, 3, 3 } ;
A multi dimensional array of strings can be initialized as shown below:
Char abc [ 3 ] [ 2 ] = { “Sunday” , “Monday” } ;
C allows you to skip the size of the array in an array initialization statement. This is called unsized array initialization. C allows arrays of more than 2 dimensions. The exact limit of dimensions is determined by the compiler we are using.
Posted by
Sunflower
at
10/10/2011 04:44:00 PM
0
comments
Labels: Array, Arrays, C, C Language, Characters, Columns, Constants, Data, Data types, Dimensions, Initialization, Integer, Languages, Multi dimensional arrays, Rows, Strings, Types, Values, Variables
![]() | Subscribe by Email |
|
Saturday, October 8, 2011
Some details about Strings and Arrays of Strings in C
Multiple character constants can be dealt with in 2 ways in C. if enclosed in single quotes, these are treated as character constants and if enclosed in double quotes, these are treated as string literals. A string literal is a sequence of characters surrounded by double quotes. Each string literal is automatically added with a terminating character ‘\0’. Thus, the string “abc” will actually be represented as follows:
“ abc \0” in the memory and its size is not 3 but 4 characters ( inclusive of terminator character ).
Arrays refer to a named list of a finite number n of similar data structure elements. Each of the data elements can be referenced respectively by a set of consecutive numbers, usually 0, 1, 2, 3, ……., n. if the name of an array of 10 elements is ARR, then its elements will be referred as shown below:
ARR [ 0 ], ARR [ 1 ], ARR [ 2 ], ARR [3], …… ARR [9]
Arrays can be one dimensional, two dimensional or multi dimensional. The functions gets() and puts () are string functions. The gets() function accepts a string of characters entered at the keyboard and places them in the string variable mentioned with it. for example :
Char name[ 21 ];
The above code declares a string namely name which can store 20 valid characters ( width 21 specifies one extra character ‘\0’ with which a string is always terminated ). The function gets() reads a string of maximum 20 characters and stores it in a memory address pointed to by name. As soon as the carriage return is pressed, a null terminator ‘\0’ is automatically placed at the end of the string. The function puts () writes a string on the screen and advances the cursor to the newline. Any subsequent output will appear on the next line of the current output by puts ().
Arrays are a way to group a number of items into a larger unit. Arrays can have data items of simple types like int or float, or even of user defined types like structures and objects. An array can be of strings also. Strings are multi dimensional arrays comprised of elements, each of which is itself an array.
A string is nothing but an array of characters only. In actual C does not have a string data type rather it implements string as single dimension character arrays. Character arrays are terminated by a null character ‘\0’. So, for this reason the character arrays or strings are declared one character larger than the largest string they can hold.
Individual strings of the string array can be accessed easily using the index. The end of a string is determined by checking for null character. The size of the first index ( rows ) determines the number of strings and the size of the second index ( columns ) determines maximum length of each string. By just specifying the first index, an individual string can be accessed. You can declare and handle an array of strings just like a two dimensional array. See an example below:
Char name [10] [20] ;
Here the first dimension declares how many strings will be there in the array and the second dimension declares what will be the maximum length of a string. Unlike C++, C has some different functions for adding or concatenating strings, checking string length and to see the similarity of two strings. The functions are namely strlen, strcmp, strcat, strrev etc and are included in header file string.h. Strings are used for holding long inputs.
Posted by
Sunflower
at
10/08/2011 08:05:00 PM
1 comments
Labels: Array of strings, C Language, Characters, Code, Constants, Data, Dimensions, Elements, Function, Inputs, Memory, Outputs, Strings, Structure, Types, Values, Variables
![]() | Subscribe by Email |
|
Wednesday, September 14, 2011
Some details about pointers and strings in C...
There doesn’t exist anything in C like real strings. A string is an array. It can be defined as an array of characters. A string is terminated by a nul character “\0”. A string can be initialized normally as follows:
Char string[10];
String[0] = ‘c’;
String[1] = ‘a’;
String[2] = ‘t’;
String[3] = ‘s’;
Another way of initializing and declaring a string is as follows:
Char string[10] = “cats”;
The following statement asks compiler to allocate 10 bytes of memory for the string entered by the user. The string can store only 9 characters and the tenth one being used for “nul” character.
We can easily access strings and their constituent characters using character pointers. The string arrays are mostly used for storing char data type elements in the memory. The array of string pointers is preferred over two dimensional arrays of characters mainly for two reasons. The first reason is by implementing array of pointers, you can make more efficient use of available memory since it consumes lesser number of bytes for storing arrays of strings. The second main reason is that an array of string pointers makes the manipulation of strings easier. You can easily exchange the positions of strings in the array using pointers without touching their memory locations. This makes managing strings very convenient. Another way of initializing a string is by using pointers like
for example:
Char string[ ] = “cats”;
Char *a;
Here is a pointer pointing to the string “string”. Pointers are another suitable way to access string arrays and modify them as we want. Since strings are composed of characters, we should use pointers to characters. The types of the variable and the pointers must match otherwise an error will be generated. Be careful that you don’t use “&” (address of) operator to assign the address of a variable to the desired pointer. If you used it, the name of the array will be used as the address of that particular array. For this reason only we do not use “&” (address of) while passing a string to the function scanf(). For example see the following code:
Int a;
Char name[10];
Scanf(“%d%s”, &a, name);
The pointer allows us to access the required character in the string because we made it to point to that string. Functions can be passed to print labels and to call the function. Below is an example:
Void printlbl(char lbl[ ])
{
Printf (“the label: %s\n”, lbl);
}
int main()
{
char lbl2[] = "abc";
Printlbl(lbl2);
}
Now if we want to pass a pointer to the string array lbl2, we will use the following code:
Char *lblptr = lbl2;
The above declared pointer can be used in the function also like shown below:
Printlbl (lblptr) ;
After execution you will observe that both the statements give the same output. Now you will ask me why so? The answer for this is that when we pass an array as a parameter or an argument to a function, a pointer is automatically created without we knowing it and the arrays are passed by reference method automatically the way a pointer is passed. So the above written code can also be written the other way as follows:
void Printlbl(char *lbl)
{
printf("the Label: %s\n",lbl);
}
a code for dynamically allocated string is given below:
string = (char *)malloc(sizeof(char) * (len+1));
Some stings can be allocated dynamically. This is done when we don’t know how much long a string will go until the program is executed or when we don’t what size of string the user will enter.
Posted by
Sunflower
at
9/14/2011 09:01:00 PM
0
comments
Labels: Arrays, C Language, Characters, Code, Compiler, Data types, Declaration, Errors, Functions, Initialization, Memory, Pointers, program, software engineering, Strings, Variables
![]() | Subscribe by Email |
|
Friday, September 9, 2011
Understanding the Structure of a C Program
The best way to get started with any programming language is to study a program, so in order to make you understand C program structure, we will take into consideration an example program whose code is:
1. /* this is a simple c program
2. Written to explain basic program structure */ -------------------------multiple line comment
3. #include
4. int main()
5. {
6. return 0;
7. }
This is the simplest C program and this program unfortunately doesn’t do anything. “#include
Functions are the basic building blocks of any program. The function “main()” is the most important function in any C program. You can say that this is the point of execution of a program. This function should exist as an entry point. Following the main is a pair of parentheses. These two parentheses indicate that the main is a function. Now coming to the opening and closing pair of braces in lines 5 and 7, are used to define the limits of a function or the program. Usually these braces contain executable statements of a function. The main() is preceded by word int. it means that this function returns an integer value. This value is returned using the “return” statement.
Now let’s take a program “abc.C” that does something. It’s same as the previous except that it has an executable statement between the braces in addition to the obligatory return statement. The executable statement calls a function which is already included in the header files as a part of the C library. The function is namely “printf()” and in order to make it print text the desired text is written with quotation marks within the parentheses of the function. The text will be displayed on the monitor when program is run. Notice the semicolon at the end of the executable statements. A semi colon in C is used as a statement terminator.
Consider the following statement:
printf("Hello World!\n");
Notice the “\n” character. The back slash is used to indicate to the compiler that a special character is being inserted. Here “n” indicates a new line. This is used whenever you want to print something in a new line. The function “printf()” prints the text and returns the carriage. Consider the following statements:
int index;
the key word int stands for integer and is used to declare a variable of type integer called index. Always keep in mind that the number of field descriptors and the number of variable definitions must be the same or else the runtime system will generate something we are not expecting. Another common and important part of C program structure is “comments”.Comments are optional but it’s good to include because they make the program more readable although they don’t mean anything to the compiler. Comments are of two types: single line comments and multiple line comments. Single line comments are used to give only one line description of a function or any other statement. A multiple line comment spans through several lines and is used to give a detailed description of a program or function.Look at the above program code for an example of comments. Another important part of a program are statements and expressions which combine variables and constants and can be assignments, function calls etc.Coming to the line breaks they are necessary to for good style formatting of your programs. This makes it easy for you to understand how your program flows when you want to maintain or modify it.You can also use “blank lines” after pre compiler declarations and declaration of new variables.Indentation should also be used in order to make your program more readable and to define the body of functions.
Posted by
Sunflower
at
9/09/2011 10:04:00 PM
0
comments
Labels: C, C Language, C program, Characters, Code, Compilation, Constants, Define, Functions, Languages, program, Statements, Structure, Values, Variables
![]() | Subscribe by Email |
|
Wednesday, September 7, 2011
How are strings and arrays defined in C?
A string can be defined as a group of characters, usually letters of the alphabet. When C is either to compare a string with another string, output it, copy it to another string, or whatever, the functions are intended to do what they are called to do until a null, which is a zero, is detected. Such strings are often called an ASCII-Z string. C treats a string as an array termination with a NULL character. C does not have a separate data type for strings and so strings exist as the arrays of characters. An extra byte must be left to store the NULL “\0”. Strings are declared as the arrays of characters. For example:
char name[25];
Strings can be fully or partially initialized depending on the requirements of the user. For example:
char fill[10] = { ‘a’, ‘ ‘, ‘r’,’o’,’p’,’l’,’a’,’n’,’e’,’\0’ };
There exist certain predefined functions for modifying strings. The library cstring.h houses all these functions. Strcpy() is used to copy one string into another string. Strlen() is used to determine the length of the string. Strcmp() is function for comparing two strings i.e., which one is bigger in terms of length. Strcat() is used to concatenate two strings. The second string is appended to the end of the first string. Strrev() is used to reverse a string alphabetically.
An array is a C derived data type and can be defined as a collection of variables of the same data type that are referenced by a common name. All arrays consist of contiguous memory locations where the lowest address corresponds to the first element and highest address corresponds to the last element. Arrays are useful when quite many elements of the same data type are needed to be stored and processed. The numbers in [ ] are called indices or subscripts. A string itself is an array of characters. Arrays are of two types namely one- dimensional arrays and multi dimensional arrays. Multi dimensional array comprises of elements which themselves are arrays. The general form of an array declaration is as follows:
Type array-name [size];
Here type states the data type of the array elements. The array name declares the name of the array, and finally the size defines how many elements will be there in the array. The data type of the array is called the base type.
A multidimensional array consists of M*N elements where M is the number of rows and N is the number of columns. It can be declared as follows:
Type array-name [rows][columns];
Where single dimensional arras can be read using a single loop, it takes nested loops to read and access the elements of a multi dimensional array. One loop is used to process the rows and the other one is used to process the columns. The arrays can be initialized during the run time as follows:
Type array-name [size 1]……….[size N]= {value list};
The value list consists of the array elements. C allows you to skip the size of arrays in an initialization statement. These types of arrays are called unsized arrays. For example:
Int abc[ ] = {1,2,3,5,7};
The best way to assign values to an array is using a "for" or "while" loop because it’s not affordable to write a separate initialization for every element. Arrays can be passed s parameters to the functions to maintain a structured design. Always keep in mind that in C subscripts start from 0. A string from an array of strings can be accessed by using pointers. But keep in mind that pointers hold only address of the strings. From there it is able to obtain the whole chunk of the contiguous memory.
Posted by
Sunflower
at
9/07/2011 06:35:00 PM
0
comments
Labels: Arrays, C, C Language, Characters, Copy, Data, Elements, Functions, Initialization, Length, Letters, Nested loops, Null, Output, Requirements, Size, Strings, User, Values, Variables
![]() | Subscribe by Email |
|