Inputting Non ASCII characters to scanf(“%s”)

后端 未结 2 946
花落未央
花落未央 2021-01-12 14:59

Is there a way one can issue non ascii hex characters to a scanf that uses %s ? I\'m trying to insert hexadecimal chars like \\x08\\xDE\\xAD and so

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-12 15:07

    When you say 'to a scanf()', presumably there is other data than just this to be supplied. Would it work to have a program, perhaps a Perl or Python script, generate the data and write the non-ASCII characters to the standard input of your program? If you need standard input to appear like a terminal, then you should investigate expect which handles that for you. This is a common way of dealing with the problem.

提交回复
热议问题