W
Walter L. Preuninger II
I need to convert escape sequences entered into my program to the actual
code.
For example, \r becomes 0x0d
I have looked over the FAQ, and searched the web, with no results.
Is there a function that can do this, or do I need to use predefined
constants or a table of the values?
Below is a sample program.
When run with the input w\rx, I want to see the output::
input 77 5c 72 78 a
output 77 d 78
Thanks,
Walter
#include <stdio.h>
#include <stdarg.h>
int main (void)
{
char input[80];
char output[80];
int i;
fgets (input, 79, stdin);
printf ("\ninput ");
for (i = 0; i < strlen (input); i++) {
printf ("%x ", input); }
strcpy (output, "");
sprintf (output, "%s", input);
printf ("\noutput ");
for (i = 0; i < strlen (output); i++) {
printf ("%x ", output); }
exit (0);
}
When run, I want to get this output:
w\rx
input 77 5c 72 78 a
output 77 d 78
code.
For example, \r becomes 0x0d
I have looked over the FAQ, and searched the web, with no results.
Is there a function that can do this, or do I need to use predefined
constants or a table of the values?
Below is a sample program.
When run with the input w\rx, I want to see the output::
input 77 5c 72 78 a
output 77 d 78
Thanks,
Walter
#include <stdio.h>
#include <stdarg.h>
int main (void)
{
char input[80];
char output[80];
int i;
fgets (input, 79, stdin);
printf ("\ninput ");
for (i = 0; i < strlen (input); i++) {
printf ("%x ", input); }
strcpy (output, "");
sprintf (output, "%s", input);
printf ("\noutput ");
for (i = 0; i < strlen (output); i++) {
printf ("%x ", output); }
exit (0);
}
When run, I want to get this output:
w\rx
input 77 5c 72 78 a
output 77 d 78