If i am inputing "Hello" and if i want to convert that word in to Binary than is there any methematical process which support either C or C++ programming language.
If you know than please tell me and try to help me.
Please tell me the whole procedure to convert Text to Binary in C or C++ programming.
I am waiting for the good and well explained answer.
Thanks.
How i can conver English Text in to Binary Language ic C or C++ programming?
I understand you want to convert A,B,C... to {0,1}, right? then. In C, all strings are character arrays, otherwise collection of characters. by converting each character u can do. as u can see each character both printable and other have a numerical value. it is in a table, ASCII table. Here the code
----------
void binary(char ch)
{ if(ch%26gt;0) binary(ch/2);
printf("%d",ch%2);
}
void toBinary(char*text)
{ for(i=0;text[i]!='\0';i++)
{ binary(test[i]);
printf("\n");
}
}
----------
i hope these two functions helps you.....
good luck.
Reply:Binary is 1's and 0's. English is a language. Text to a computer is also known as a character set. For you to convert a character a into its binary you need to understand the conversion table. The character set that you are probably interested in is ASCII. which consists of both printable and non printable characters.
Almost every programming language can convert between ASCII and hex, or ASCII and binary.
Reply:I don't know about C or C++, but I know of a good text to binary and binary to text converter...
Reply:It has been a while that I have written any C programs so please read my reply with caution ! I am replying just because I was so fond of this language during my college days ;-)
The answer give by person before me is right if you really wanted to have binary representation of english characters;
If you meant ASCII representation(a=32,A=65 etc.) then here is how you can achieve it.
In C there are plenty of ways you can achieve it
1)
Characters can be printed as numbers by using format specifiers
printf("%d%d%d%d%d",'h','e','l','l','o...
2)
char c='h';
int a=c;
a will have the ASCII number for character in question
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment