Use C++ to read in url data

Hello

I am trying to write a C++ program that could read in quote info from yahoo "http://finance.yahoo.com/d/quotes.csv?s=YH&f=sl1d1t1c1ohgv&e=.csv"

I know this can be done easily with php and other scripting language.  Is there a way to do it so that I can get the data and be able to display in in my C++ application directly?

Thanks,
cdlovesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gckcmcCommented:
sure....it is a standard CSV format...basically you just parse the input stream breaking on commas.  you can store the data however you want...gimme a minute and I'll show you some code.
0
gckcmcCommented:
btw, do you have any system level dependencies, like unix vs windows?  
0
cdlovesAuthor Commented:
window
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

gckcmcCommented:
well, first thing you could do is go grab the sample dll library code from the 3W, which provides you http access to windows environment.  http://www.w3.org/Library/User/Platform/WinDLL.html#io

I'm assuming you actually want to do this streaming, which is what you would need the above code to get you the 'get's...if you are actually saving the csv files to a disk and just want to parse them in your c++ file, you can skip this step, and just go to a while not EOF loop, doing char parsing with commas as the delimiter test.
0
mrwad99Commented:
>>  Is there a way to do it so that I can get the data and be able to display in in my C++ application directly?

I would do it the easy way
      URLDownloadToFile(NULL,"http://finance.yahoo.com/d/quotes.csv?s=YH&f=sl1d1t1c1ohgv&e=.csv","c:\\MyCSV.csv",0,NULL);      

ifstream input("c:\\MyCSV.csv");
char oneLine[512];

while (input.good()) {
      input.getline(oneLine, 512);
      // Do whatever with one line of the CSV file....
}

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cdlovesAuthor Commented:
cg,
The sample dll file you mentioned is windll, I assume?  If so how do I include it in the project and how to use it? The link doesn't help much in that regard.

mrwad,
I included urlmon.h file in my project and used your sample code but the compiler complained that it couldn't resolve UrlDownLoadToFile. I already have SDK installed.
0
mrwad99Commented:
Yeah, you need to link with Urlmon.lib.  Add that in project->settings->Link->project options if you are using VC++.  
0
gckcmcCommented:
yes it is a windll file.  it is in the project settings, assuming your using msvc, you include it in the settings there.  mrwad99's solution will work if you want to use temp files....if not, then you need to stream it.
0
mrwad99Commented:
cdloves:

Did you link with that DLL ?
0
cdlovesAuthor Commented:
Yes, I got it to work mrwad.  Thanks both for helping.
0
mrwad99Commented:
cdloves:

Glad to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.