I am new at this form and have already a problem. To my person, I have a mechanical engineering background and have little to none knowledge in C++ programming. Therefore I would really appreciate your help.
I have written a program (see below) that translates text into ASCII code (letter by letter into three digit numbers) and writes the result one below the other. What I need now is to take/grab the three digit values one by one and convert them into radiants (rad = value*pi/180). However, I don't know how to do that. I have already read something about pointers but I am just as clever (stupid) as before.
What I want to achieve is:
letter h = 117
in radians 2.0420352 (117*pi/180) with 6-7 decimal places
I would be really thankful if someone out there would/could show me how to do that (a small example would probably help me further). A big thank you in advance.
@ Zaita, many thanks for you help. It seems to work.
Now what I want to do is to make it work the other way round. In other words, input is the radiant and the output should be the text. Is it more complicated this way round?
Does someone know how to convert ASCII back to text? Is there something similar to (int c = __toascii(t[i]);) but the other way round?
I appreciate any help I can get. Thanks.
Unfortunately you've already been brainwashed by silly MS stuff...
And you are mixing C and C++...
In C and C++, a number is a number is a number. The only difference between a char and an int is that the first is assumed to represent a printable ASCII character and the second is not. So they are displayed differently. But they are both just numbers. You can try this to see the difference:
1 2 3 4 5 6 7 8 9 10 11 12
#include <cstdio>
usingnamespace std;
int main()
{
char c = 'a'; // ASCII value 97
char d = 97; // ASCII code for 'a'.
printf( "c = %03d = \'%c\'\n", c, c );
printf( "d = %03d = '\%c\'\n", d, d );
return 0;
}
All the __toascii() routine does is drop all bits other than 0..6: strict ASCII codes are 7-bit entities, not 8 or 9, etc.