I need a way to print(and later on compare - but for now just print) characters 2 by 2 as in:
I have a string of 1F190307091810 and I have to print out:
1F 19 03 04 09 18 10.
I need this for Baudot code(I have segments of code given to me and I have to compare letters and numbers - together, two by two)
If you don't understand something please ask(I know I explain this in a weird way).
When you store it into a variable, make it so it's like:
string var1 = "1F 19 03 04 09 18 10"
And then print it. Or, do something like: printf("1F 19 03 04 09 18 10") or printf(var1) and it will be like it is in the variable.
Sorry I did the variable setting in C++. Just make a string in C and use same concept for storing.
Or you could try using a array and have the items for amount of characters and print first 2 and then do " " and then the next two and so on. That would work as well.
If you need to print more and more strings, the most efficient way in my opinion is to make a function with a parameter for the text to be printed two by two. Then, in that function, make a array and organize the characters so 1 char from the string is in it. Then, print out 2 characters, then " " and then another two until the string is complete. That way you could call the function and submit any string, and have it automatically printed out the way you want it.
Sorry I couldn't provide a code :(
At the moment, C for Windows development isn't my best language.
The issue is that I don't need to have same number of pairs,but I will have even number of characters - because 2 bytes make a letter or a number, so on that note can I use strlen to measure the size of string and divide it by 2 to get the number of paired elements ?
The other problem that I'm having atm is that I have to use dynamically allocated memory for each string(which I did) but I'm lost when I need to extract the elements 2by2.
If you want I can link code here.
Thanks for your help.
And yeah, just to say one more thing. I need to keep an infinite loop with one condition. When I type in "Stop Bruce Li" the program should exit( I can't make an infinite loop with this condition - whenever I enter second string after the first one my program crashes).
Tyranneo, google Baudot code. I have to make a code that will read ciphered message and decipher it. In Baudot's code it functions in 2b2s where combination of 2 letters of numbers mean some letter in alphabet or number.