Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-17-2007, 12:12 PM   #1 (permalink)
cspoon
Recruit
 
Join Date: Jul 2007
Posts: 2
cspoon is on a distinguished road
Compare GUID with string

Hi all.
Im an absolute noob and having trouble comparing a GUID with a String in c++.
code:

if(typeGUID == "7c5a9de3") {
printf("match found!");
}

error:
error C2679: binary '==' : no operator defined which takes a right-hand operand of type 'char [9]' (or there is no acceptable conversion)

I tried to convert (GUID>string or string>GUID) but no such luck.
Any ideas ?
cspoon is offline   Reply With Quote
Old 07-18-2007, 07:21 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,712
redhead is on a distinguished road
I've moved the thread here, since GUID is part of the Win32 API, in order to compare a GUID structure with a string type, you need to use the CoCreateGUID function.
Code:
...
HRESULT hr = NULL;
GUID guid;
int guid_len;
wchar_t guid_ch[9];
...
hr = CoCreateGuid (&guid);
if (FAILED (hr)) 
  return NULL;
guid_len = ::StringFromGUID2 (guid, guid_ch, 9);
if (guid_len == 0)
  return E_FAIL;
if(guid_ch == "7c5a9de3")
  std::cout << "match found!" << std::endl;
...
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help for another program Androto Standard C, C++ 54 10-15-2004 07:21 AM
GUID to string conversion milena Platform/API C++ 1 09-14-2004 12:04 PM
From C to Java HighterDK Java 11 07-13-2004 07:15 PM


All times are GMT -8. The time now is 09:28 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting