C program to get the ascii string from a string

Example diagram of the printf function in the ...
Example diagram of the printf function in the C programming language (Photo credit: Wikipedia)

Lot of times, you would like to get the complete string in hex or ascii format and if you are one of them then this is something that will be helpful for you 🙂

Example output:

lp-amita[d=~/bin]> ./ascii aamit
String – aamit, Length – 5

String : aamit
Hex    : 0x61616d6974
Dec    :   9797109105116

And the source code:


/*n* =====================================================================================
*       Filename:  ascii.c
*    Description:  ascii to dec
*        Version:  1.0
*        Created:  03/02/2012 12:08:49 PM
*       Revision:  none
*       Compiler:  gcc
*         Author:  Amit Agarwal (aka)
*  Last modified: Thu Mar 08, 2012  08:47PM
* =====================================================================================
void main (int argc, char **argv){
    int i=0;
    char a[200]="",b[200]="";
    printf("String - %s, Length - %dn",argv[1],strlen(argv[1]));

    while (i < strlen(argv[1])){
    printf ("n");
    printf ("String : %sn",argv[1]);
    printf ("Hex    : 0x%sn", a);
    printf ("Dec    : %sn", b);
Enhanced by Zemanta

10 Keyboard Techniques To Create Cool Symbols

\"Thumbnail\"All of us use the keyboard to create symbols daily. Look at the thumbnail. That’s a simple symbol created with just four keys.

Symbols existed even before the alphabets. Over the years they have been part of folklore, myths and legends. Some have stayed on as indelible marks. Some, like the swastika, are better forgotten. Symbols have remained potent. If you doubt their visual power, then look no further than logos. People shell out millions for a three-pointed star on a sleek hood or a prancing horse. Puzzled? The first one is the Mercedes logo and the latter is Ferrari’s.

In this post we will take a look at some symbols or images that we can reproduce using just the keyboard. The superset of creating images using letters/symbols on the keyboard goes by the name of ASCII (American Standard Code for Information Interchange) art. You need two things to draw ASCII art anywhere online…a keyboard and lots of patience.

How Do We Create Cool Symbols Using The Keys On Our Keyboard?

Text art/ ASCII art can be drawn using any text editor, online or offline. The simplest is Notepad on Windows or TextEdit for Mac. More advanced word processors have features which are more adept at selection and alignment functions like Overtype and Insert.

Can text art be learned and are there any special techniques to create cool figures?

The answer to the first is yes, it’s fairly easy to learn. There are some basics of course that need to be kept in mind. The rest as they say is practice.

Some basic techniques for keyboard symbols are :

  1. Use a fixed width (Courier, Monaco, and Fixedsys) font, to draw your symbols because every type of computer has them. Also called as a monospaced font, they are fonts whose letters each occupy the same amount of space and thus they are also easier to align with one another.
  2. Experts speak about noticing the difference between serif (with a short line at the end of the character) and sans serif (without the line at the end) fonts for text art. The display may differ from one computer to the next depending on the default type of font. One advice usually is to use the vertical bar (|) instead of the capital I (I) to draw vertical lines with the sans serif font.
  3. Draw in the Overtype mode on your word processor. This makes it easier to put in another character without re-aligning the neighboring ones.
  4. Use the Space key instead of the Tab key.
  5. Draw a rough sketch of the figure on paper and then put in place keyboard symbols and letters that bests approximate the angles and curves of your figure. For instance, o or @ for eyes, for hair etc. The most common symbols used in ASCII art are: / | – _ ( )
  6. Start small with simple symbols or figures. Example – a rose or a face.\"keyboard
  7. Begin from a simple area of the figure which has a shape that’s easy to type in.
  8. Go for close approximation rather than pinpoint accuracy…after all, accuracy is more suited for line art.
  9. Correct your mistakes early because leaving them for later will mar the precision and placement of symbols.
  10. Free your imagination!

Read more at : http://feedproxy.google.com/~r/Makeuseof/~3/F3o92_GVtP0/