Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,430 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,315 people online right now. Registration is fast and FREE... Join Now!




URL Variable

 
Reply to this topicStart new topic

URL Variable

jasonprince2
21 Jan, 2008 - 07:24 PM
Post #1

New D.I.C Head
*

Joined: 6 Jun, 2007
Posts: 19


My Contributions
What type of C++ variable is a URL?
User is offlineProfile CardPM
+Quote Post

girasquid
RE: URL Variable
21 Jan, 2008 - 07:48 PM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,294



Thanked: 18 times
Dream Kudos: 725
My Contributions
String?
User is online!Profile CardPM
+Quote Post

jjhaag
RE: URL Variable
21 Jan, 2008 - 09:48 PM
Post #3

me editor am smartastic
Group Icon

Joined: 18 Sep, 2007
Posts: 1,789



Thanked: 2 times
Dream Kudos: 775
Expert In: C,C++

My Contributions
It's probably a "string" of some sort - either a C-style string (character array with a terminating NULL) or an STL string. But it really depends on how you've chosen to store it.


Is what you're really asking "How should I store a URL in C++?"
User is offlineProfile CardPM
+Quote Post

jasonprince2
RE: URL Variable
22 Jan, 2008 - 10:15 AM
Post #4

New D.I.C Head
*

Joined: 6 Jun, 2007
Posts: 19


My Contributions
Kind of. The setup is that you have a text box, and you type in a URL for a website. The string (from the text box) is converted into Url (for the web browser), and then the Url is set in the web browser.

My problem is I don't know how to convert 'System::String' into 'System::Uri'. I have tried many things, like:
Convert::ToUri
Convert::ToSUri
Convert::ToSystem::Uri
Convert::ToUri
Convert::ToUrl
But most of them get build errors.

That is my problem.
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: URL Variable
22 Jan, 2008 - 10:29 AM
Post #5

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,347



Thanked: 51 times
Dream Kudos: 25
My Contributions
Managed C++, eh? What version are you using? Try just using the constructor:
CODE

Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" );

the default constructor takes a String as a parameter.

Code From MSDN:

http://msdn2.microsoft.com/en-us/library/z6c2z492.aspx
User is online!Profile CardPM
+Quote Post

jasonprince2
RE: URL Variable
22 Jan, 2008 - 03:59 PM
Post #6

New D.I.C Head
*

Joined: 6 Jun, 2007
Posts: 19


My Contributions
Sorry, but I'm kind of new to all this. I guess I still don't know what to do.
User is offlineProfile CardPM
+Quote Post

nirvanarupali
RE: URL Variable
22 Jan, 2008 - 04:10 PM
Post #7

D.I.C Stomach
Group Icon

Joined: 1 Aug, 2007
Posts: 994



Thanked: 4 times
Dream Kudos: 375
My Contributions
Here is another example:
CODE
//This will open a browswer and the website.
#include <windows.h>

int main()

{  
    
    char website[MAX_PATH]="http:\\www.dreamincode.net";
    
    ShellExecute(NULL,"open",website,NULL,NULL,SW_MAXIMIZE);
    
    return 0;
}

User is offlineProfile CardPM
+Quote Post

Amadeus
RE: URL Variable
22 Jan, 2008 - 04:20 PM
Post #8

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,347



Thanked: 51 times
Dream Kudos: 25
My Contributions
Problem is, the user is using managed C++, not actual standard C++. The objects are different. Managed C++ (or C++.NET) is MS's version of C++ for the .NET platform.

See the link I posted.

@jasonprince: Not sure where the disconnect is here - if you visit the link i gave, you'll see an example - the very one I provided. You want to have a URI object, correct? the code I provided declares a URI object named baseuri, and instantiates it through it's constructor with a value of thee website URL. Simply pass the constructor the value of the String object you have.
User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 11:41AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month