<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Main Function on Amit Agarwal Linux Blog</title>
    <link>/tags/main-function/</link>
    <description>Recent content in Main Function on Amit Agarwal Linux Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Fri, 13 Apr 2012 03:39:54 +0000</lastBuildDate>
    
	<atom:link href="/tags/main-function/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Convert string to hex.</title>
      <link>/2012/04/13/convert-string-hex/</link>
      <pubDate>Fri, 13 Apr 2012 03:39:54 +0000</pubDate>
      
      <guid>/2012/04/13/convert-string-hex/</guid>
      <description>&lt;p&gt;If you want to use snoop or &lt;a class=&#34;zem_slink&#34; title=&#34;Tcpdump&#34; href=&#34;http://www.tcpdump.org/&#34; rel=&#34;homepage&#34; target=&#34;_blank&#34;&gt;tcpdump&lt;/a&gt; with &lt;a class=&#34;zem_slink&#34; title=&#34;advanced search&#34; href=&#34;http://search.twitter.com/advanced&#34; rel=&#34;homepage&#34; target=&#34;_blank&#34;&gt;advanced search&lt;/a&gt; in the packet, then you would need to convert the string to hex string. For this, either you can use a web search and find some &lt;a class=&#34;zem_slink&#34; title=&#34;Web application&#34; href=&#34;http://en.wikipedia.org/wiki/Web_application&#34; rel=&#34;wikipedia&#34; target=&#34;_blank&#34;&gt;web application&lt;/a&gt; to do that or you can use a simple C program like this 🙂&lt;/p&gt;
&lt;pre class=&#34;brush: c; gutter: true; first-line: 1&#34;&gt;/*
* =====================================================================================
*
*       Filename:  ascii.c
*
*    Description:  ascii to dec
*
*        Version:  1.0
*        Ceated:  03/02/2012 12:08:49 PM
*       Revision:  none
*       Compiler:  gcc
*
*         Author:  Amit Agarwal (aka), amit.agarwal@roamware.com
*  Last modified: Thu Mar 08, 2012  08:47PM
*
* =====================================================================================
*/
void main (int argc, char **argv){
    int i=0;
    char a[200]=&#34;&#34;,b[200]=&#34;&#34;;
    printf(&#34;String - %s, Length - %d\n&#34;,argv[1],strlen(argv[1]));
    /*printf(&#34;%x\n 0x&#34;,argv[1]);*/
    while (i &amp;lt; strlen(argv[1])){
        /*printf(&#34;%c&#34;,argv[1][i]);*/
        sprintf(a,&#34;%s%x&#34;,a,argv[1][i]);
        /*printf(&#34;a=%s\n&#34;,a);
        printf(&#34;b=%s\n&#34;,b);*/
        sprintf(b,&#34;%s%d&#34;,b,argv[1][i]);
        i++;
    }
    printf (&#34;\n&#34;);
    printf (&#34;String : %s\n&#34;,argv[1]);
    printf (&#34;Hex    : 0x%s\n&#34;, a);
    printf (&#34;Dec    : %s\n&#34;, b);

}&lt;/pre&gt;
&lt;h6 class=&#34;zemanta-related-title&#34; style=&#34;font-size: 1em;&#34;&gt;
  Related articles
&lt;/h6&gt;
&lt;ul class=&#34;zemanta-article-ul&#34;&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://seclists.org/fulldisclosure/2012/Apr/13&#34; target=&#34;_blank&#34;&gt;Re: iis bug&lt;/a&gt; (seclists.org)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://www.daniweb.com/software-development/c/threads/420145/problem-of-file-transfer-in-socket-programming&#34; target=&#34;_blank&#34;&gt;Problem of file transfer in socket programming&lt;/a&gt; (daniweb.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://jetcracker.wordpress.com/2012/02/23/c-echo-implementation/&#34; target=&#34;_blank&#34;&gt;[Unix C] ECHO Implementation&lt;/a&gt; (jetcracker.wordpress.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://sourcecode4all.wordpress.com/2012/04/03/character-stuffing-in-c/&#34; target=&#34;_blank&#34;&gt;Character Stuffing in C&lt;/a&gt; (sourcecode4all.wordpress.com)
  &lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;zemanta-pixie&#34; style=&#34;margin-top: 10px; height: 15px;&#34;&gt;
  &lt;a class=&#34;zemanta-pixie-a&#34; title=&#34;Enhanced by Zemanta&#34; href=&#34;http://www.zemanta.com/&#34;&gt;&lt;img class=&#34;zemanta-pixie-img&#34; style=&#34;border: none; float: right;&#34; src=&#34;https://i1.wp.com/img.zemanta.com/zemified_e.png?w=688&#34; alt=&#34;Enhanced by Zemanta&#34; data-recalc-dims=&#34;1&#34; /&gt;&lt;/a&gt;
&lt;/div&gt;</description>
    </item>
    
  </channel>
</rss>
