#include <iostream>
#include <string>
using namespace std;
int main()
{
string website;
cout << "Enter a website : ";
cin >> website;
string a = "start ";
string b = a + website;
system ( b.c_str() );
cin.get();
cin.get();
return 0;
}
sample input:
Enter a website : www.google.com
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
>What is c_str() doing?
Why don't you read a C++ reference and find out?
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>Because he obviously knows what it is already
Your logic (or lack thereof) has stumped me. Can you explain what you mean and why you don't seem interested in doing as I suggested?
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>Why would I go into a C++ reference and go looking for the command when someone like you could clearly help me quicker
Gotta give him credit for that! Bless.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
>Why would I go into a C++ reference and go looking for the
>command when someone like you could clearly help me quicker
Because I'll call you a lazy retard and refuse to help you for the rest of eternity. And I'll encourage everyone else to do the same thing because you're clearly not interested in learning, which is what Daniweb is about. If you don't respect us, we won't respect you.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Sorry slick, you came here asking for us to take time out of our lives to hand you answers on a silver platter because you're too lazy to search google for 5 whole seconds. That's made painfully clear with the following incredibly arrogant statement:
Why would I go into a C++ reference and go looking for the command when someone like you could clearly help me quicker
We're not your personal slaves, and after this display of the very attitude that we abhor the most, I recommend you leave Daniweb or start a new account because you're not likely to get any help in the future.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Why would I go into a C++ reference and go looking for the command when someone like you could clearly help me quicker
Because, give you bread and you may eat for one day, but teach you how to grow food and you will eat forever. Yes, Narue, or anyone else here, could easily just give you the answer and the next time you have another question you will have no clue how to get the answer so you will be right back here asking again. But if you learn how to look up the answers to your questions you will be able to answer your question yourself, saving you lots of time and effort. Its to your own benefit that you learn how to look up the answers to your questions, and ask us only when you can't find the answers somewhere else.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
What is c_str() doing?
>What is c_str() doing?
Why don't you read a C++ reference and find out?
Why would I go into a C++ reference and go looking for the command when someone like you could clearly help me quicker
I am very capable of learning on my own. I have books and I study the language. My questions was on a very small piece of code which I assumed wouldn't be nearly as easy to find as a conventional command such as cout.
I won't make the mistake of thinking this forum was for C++ support again...
If you already have a c++ book then why didn't you just look up your question in your book? I'm certain there is a description of std::string class in that book. If there isn't, they you need a different book.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
In the sort run yes you are right that it would save time. But it hurts you in the long run -- now that you have found the answer on your own I'll bet you will know where to look next time. And, if you are like me, during your research you read lots of stuff that will be useful to you in the future.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343