在C中打印空终止字符数组 [英] Print null terminated character array in C

查看:93
本文介绍了在C中打印空终止字符数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以下列格式从驱动程序获取字符串

\ U sers \ abc \ A pp D ata \

字符数组,我希望输出像

\ Users \ abc \ AppData \无循环

可以吗?



我尝试了什么:



iam getting string from driver in following format
\ U s e r s \ a b c \ A p p D a t a\
in char array and i want output like
\Users\abc\AppData\ without loop
can it be possible ?

What I have tried:

fwrite(notification->FileName, sizeof(char), 50, stdout);

推荐答案

如果数据是您显示的形式,其中驱动程序中的每个字符用空格分隔,那么不,你不能删除或忽略没有循环的那些。



但是......它们是空的,还是驱动程序传递给你16位的Unicode字符,以及你假设7或8位ASCII?因为如果它 - 并且我认为它似乎可能 - 那么将您正确接收的数据视为Unicode将是一个更好的解决方案。我首先看看驱动程序的详细信息,看看它给你的确切内容 - 现代套件需要一种或另一种形式的Unicode,所以你很可能只是错误地对待它。
If the data is in the form you show, where each characters from the driver is separated by spaces then no, you can't remove or ignore those without a loop of some from.

But ... are they nulls, or is the driver passing you 16 bit Unicode characters, and you are assuming 7 or 8 bit ASCII? Because if it is - and I'd say it seems likely - then treating the data you receive correctly as Unicode would be a much better solution. I'd start by looking at the driver details and see exactly what it says it gives you - modern kit expects Unicode of one form or another, so it's quite likely that you are just treating it wrongly.


这篇关于在C中打印空终止字符数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆