Jackey's 感悟

Do Research

>HexString

>


/**
* File: hexstring.c
* Author: Lvlin
* Date: 星期日, 九月 21 2008
* Abstract: get the C pattern string for inputs
*
*/
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char * argv[])
{
char c=0;
while(EOF != scanf("%c",&c))
{
if('\n' == c)
// ignore the input of carry,
// print it directly
printf("\n");
else
// & 0xFF to keep the only low 8 bits
printf("\\x%x",c & 0xFF);
}
printf("Done!\n");
return 0;
}

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google photo

You are commenting using your Google account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s

%d 博主赞过: