Monthly archive for February 2010

What is hashing in c?

February 22, 2010 | Filed Under C | 1 Comment

Hashing is a process for  message digest. Hash  value  is the collection of text.

Producing hash values for accessing data or for security. A hash value (or simply hash), also called a message digest, is a number  generated from a string of text. The hash is substantially smaller than the text itself, and is generated by a formula in such a way that it is extremely unlikely that some

Hashing is also a common method of accessing data records. Consider, for example, a list of names:

  • John Smith
  • Sarah Jones
  • Roger Adams
  • To create an index, called a hash table, for these records, you would apply a formula to each name to produce a unique numeric value. So you might get something like:

  • 1345873 John smith
  • 3097905 Sarah Jones
  • 4060964 Roger Adams
  • Then to search for the record containing Sarah Jones, you just need to reapply the formula, which directly yields the index key to the record. This is much more efficient than searching through all the records  till the matching record is found.

    Article written by admin

    What is static variable ?

    February 22, 2010 | Filed Under C | Comments Off

    Basically it has three core feature.

    1. It retains the value between function calls.
    2.By default function is extern..so it will be visible from other files if the function declaration is as static..it is invisible for the outer files

    3. By default we can use the global variables from outside files If it is static global..that variable is limited to with in the file.

    #include <stdio.h>

    int variable = 10;

    main(){

    int i = 0;
    void useStatic();
    style="color: #7f0055;"> #000000;">useStatic();
    printf("after 1st call \n");
    useStatic();
    printf("
    after 2nd  call \n");
    useStatic();
    printf("
    after IIIrd call \n");

    }
    void useStatic()
    {
    static int j = 0;
    int k = 10;
    printf("value of j %d k %d",j,k);
    j=j+10;
    }

    value of j 0 k 10 After 1st call
          value of j 10 k 10 After IInd call
          value of j 20 k 10 After IIUrd call
    Article written by admin

    Generate Unique number in php and mysql

    February 16, 2010 | Filed Under PHP | Comments Off

    There are number of way to generate unique number or id in mysql  and  php.

    Using Rand() function. we can get random data with in  limit

    SELECT  *   FROM company ORDER BY RAND() LIMIT 10
    
    
    
    <?
     echo str_replace ("}","",str_replace("{","",com_create_guid()));
    ?>
    <?$number = mt_rand(500 pan>,1000); ?>
    
    
    <? $uniqid = date('U') . mt_rand(0,9); ?>
    
    <? echo time();?>
    
    Article written by admin

    Get file extension using PHP

    February 16, 2010 | Filed Under PHP | Comments Off

    There are number of way to get file extension in php.
    function getFileExtension($filename)
    {
    $fileinfo= pathinfo($filename);
    return $fileinfo['extension'];
    }

    $ext = end(explode(‘.’, $file));

    $ext = substr(strrchr($file, ‘.’), 1);

    $ext = substr($file, strrpos($file, '.') + 1);
    
    $ext = preg_replace('/^.*\.([^.]+)$/D',  '$1', $file);
    
    $exts  =split("[/\\.]", $file);
    
    $n = count($exts)-1;
    $ext = $exts[$n];
    
    Article written by admin

    Show child Pages of a specific parent Page

    February 5, 2010 | Filed Under PHP, Wordpress | Comments Off
    you can use below code to   show all child of
     parent who has  id 10.
    <?php wp_list_cats('child_of=10'); ?>
    
    you   can also use this
    
    <?php wp_list_pages('child_of=10&
    sort_column=post_title&title_li=')?>
    
    
    Article written by admin

    How to Show parent page title even on child page

    February 5, 2010 | Filed Under PHP, Wordpress | Comments Off
    <?php
    if($post->post_parent)   {
        $parent_title = get_the_title($post->post_parent);
        echo $parent_title;
    }  else {
       wp_title('');
    }
    ?>
    Article written by admin

    How to kill a MySQL query?

    February 3, 2010 | Filed Under MySQL, PHP | Comments Off

    If you fired a query, that takes more time to complete their execution.
    but you want to stop this query.
    To stop this query you must use Kill command to achieve it.
    Follow two step to kill your query.
    mysql> SHOW PROCESSLIST;
    above command will show all running process on the server.
    Here  you will see thread ID return by above command.
    mysql> KILL 22;
    kill thread 22  to kill your query.

    Article written by admin

    © PHPInterviewQuestion.com 2009 - 2012

    eXTReMe Tracker