Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2005

Tip: Looking for answers? Try searching our database.

Hex to Decimal/ Search in a string/ How to use MSDN?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
yinyz - 18 Jul 2005 11:06 GMT
I would like to acquire data from a USB device. The device
send to PC data in strings like "0xa0 oxa1 oxa2...". I should
have to :

1,searching in the strings and pick up useful data like "0xa1",
"0xa2" and so so.
2,convert them from Hex data to decimal data.
3,save to a array.

How could I do it?

I am a new commer. I often find that I can't find the right place
in MSDN for the questions. Would you tell me how to use MSDN for
the above questions?
Jochen Kalmbach [MVP] - 18 Jul 2005 12:20 GMT
Hi yinyz!
> I would like to acquire data from a USB device. The device
> send to PC data in strings like "0xa0 oxa1 oxa2...". I should
[quoted text clipped - 4 lines]
> 2,convert them from Hex data to decimal data.
> 3,save to a array.

1. Use "strtok" to separate the string
2. Use strtol(..., 16) to convert to int
3. Store it in an int-array or std::vector<int>

Signature

Greetings
  Jochen

   My blog about Win32 and .NET
   http://blog.kalmbachnet.de/

Hendrik Schober - 20 Jul 2005 11:03 GMT
> I would like to acquire data from a USB device. The device
> send to PC data in strings like "0xa0 oxa1 oxa2...". I should
[quoted text clipped - 6 lines]
>
> How could I do it?

 You could use string streams:

   #include <sstream>

   //...
   std::vector<int> result;
   std::istringstream iss("0xa0 0xa1 0xa2");
   for(;;) {
     int i;
     iss >> std::hex >> i;
     if( !iss.good() ) break;
     result.push_back(i);
   }
   if( !iss.eof() ) error();
   //...

> I am a new commer. I often find that I can't find the right place
> in MSDN for the questions. Would you tell me how to use MSDN for
> the above questions?

 I don't think you'll find an explanation
 for the above in the MSDN lib. It's a
 reference, not a text book.

 Schobi

Signature

SpamTrap@gmx.de is never read
I'm Schobi at suespammers dot org

"Coming back to where you started is not the same as never leaving"
Terry Pratchett


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.