Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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);
Posted
Updated 6-Sep-18 21:27pm
Comments
Richard MacCutchan 7-Sep-18 4:46am    
printf("%S\n", notification->FileName);
The upper case S assumes the data is Unicode.
srilekhamenon 7-Sep-18 8:36am    
iam getting this output
Warning C4477 'printf' : format string '%S' requires an argument of type 'unsigned short *', but variadic argument 1 has type 'UCHAR *'

1 solution

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.
 
Share this answer
 
Comments
srilekhamenon 7-Sep-18 4:42am    
yes sir these spaces are null character
OriginalGriff 7-Sep-18 4:47am    
Then the chances are that this is 16 bit Unicode data - so check the driver documents, and then look to see if your C compiler supports Unicode. Some will, some won't - C is a very old language!
srilekhamenon 8-Sep-18 13:34pm    
thankyou sir i solved my problem by using conversion function WideCharToMultiByte

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900