473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using the cURL executable..

Ok, here is my code for my program:

"// CheckButton.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
#include <process.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string html;
system("curl.exe http://www.google.com");
html = stdout;
return 0;
}"

Basically what it does so far (or should do) is to get the HTML from
google.com. When I try and place stdout into html it doesn't work. Here
is my compile info:

------------------------------------------
Compiling...
CheckButton.cpp
c:\documents and settings\jason\my documents\visual studio
2005\projects\checkbutton\checkbutton\checkbutton. cpp(15) : error
C2679: binary '=' : no operator found which takes a right-hand operand
of type 'FILE *__w64 ' (or there is no acceptable conversion)
c:\program files\microsoft visual studio
8\vc\include\xstring(875): could be
'std::basic_string<_Elem,_Traits,_Ax>
&std::basic_string<_Elem,_Traits,_Ax>::operator =(const
std::basic_string<_Elem,_Traits,_Ax> &)'
with
[
_Elem=char,
_Traits=std::char_traits,
_Ax=std::allocator
]
c:\program files\microsoft visual studio
8\vc\include\xstring(880): or 'std::basic_string<_Elem,_Traits,_Ax>
&std::basic_string<_Elem,_Traits,_Ax>::operator =(const _Elem *)'
with
[
_Elem=char,
_Traits=std::char_traits,
_Ax=std::allocator
]
c:\program files\microsoft visual studio
8\vc\include\xstring(885): or 'std::basic_string<_Elem,_Traits,_Ax>
&std::basic_string<_Elem,_Traits,_Ax>::operator =(_Elem)'
with
[
_Elem=char,
_Traits=std::char_traits,
_Ax=std::allocator
]
while trying to match the argument list '(std::string, FILE
*__w64 )'

May 24 '06 #1
4 5030
Chiefbutz wrote:
Ok, here is my code for my program:

"// CheckButton.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
#include <process.h>
Non-standard.
#include <iostream>
#include <fstream>
Unused.
#include <string>
using namespace std;
int main()
{
string html;
system("curl.exe http://www.google.com");
html = stdout;
stdout is a C-style file handle (i.e. FILE*). You can't assign a FILE*
to a std::string because there is no conversion (constructor) or
assignment operator for std::string that accepts a FILE*, which is the
reason for your errors.

You need to use a platform-specific function (<OT>e.g., dup2()</OT>) to
do what you're trying to accomplish, but you'll need to seek help in a
newsgroup for your platform since this is off-topic here. See this FAQ
for what is on-topic here and for a list of possible places you can
post:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
return 0;
}"

[snip]

Cheers! --M

May 24 '06 #2
Chiefbutz wrote:
Ok, here is my code for my program: system("curl.exe http://www.google.com");
html = stdout;
Please switch to a softer language, such as Ruby, for these tasks. C++ is
.... hard.

In Ruby (or even in certain other soft languages), what you need is this:

html = `curl.exe http://...`

Note the back-ticks `.

The equivalent in C is roughly...

FILE * handle = _popen("curl.exe http://...");

....but now you must read the handle's contents into a string. There's no
equivalent for C++ that uses C++'s more advanced library.

Next...
2005\projects\checkbutton\checkbutton\checkbutton. cpp(15) : error
C2679: binary '=' : no operator found which takes a right-hand operand
of type 'FILE *__w64 '


Right. The left side is a string, and the right side is the stdout file
handle. They are different types, and assigning them to each other is
meaningless. stdout refers to your own program's output, not the output that
system() saw.

I would use a simpler language that provides all the stuff you need, out of
the box. Ruby also comes with an HTTP library, so you wouldn't even need to
shell to curl.exe.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
May 24 '06 #3
mlimber wrote:
You need to use a platform-specific function (<OT>e.g., dup2()</OT>) to
do what you're trying to accomplish...


Mr Manners reminds the Gentle Poster that when you give off-topic advice,
you should still try to give the best advice in the circumstances. You
should provide dup2() with the caveat that a poster has not yet learned C++
should switch to a language closer to their domain. If the poster followed
your exact advice, their project would take much longer.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
May 24 '06 #4
I figured out what to do.

May 24 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Geoff Soper | last post by:
I would like to get the HTTP status code of a URL using PHP. I think CURL is the way to go but I can't see how to do it. I see I can use curl_getinfo on the CURL session after I've curl_exec'ed it...
1
by: Rory | last post by:
I'm just starting to use cURL and having trouble accessing https pages. All I want to do at this stage is get an https page and display it, just to test the https get is working. However, I always...
1
by: Paul | last post by:
alllow_url_fopen if set to off. For some reason I can not access domxml_open_file(). And I need to read an xml feed. I can access the feed using cURL: $feed =...
0
by: elrondrules | last post by:
hi need some help from the experts in this group as to how to do the following i have a http listener (A) that has subscribed to a process (B) and listening on a port.. now based on some...
13
by: princei2007 | last post by:
hi, iam just a beginner with php and curl.i search a lot but not able to find out the find out the problem i am gating. I am first sending data to a php a file then using CURL on the php file iam...
3
by: JDS | last post by:
So, I'd like to create the following scenario: 1) Use cURL library within PHP (cURL + "Cookie Jar", et.al) to create a virtual browser session that "logs in" to a remote site. (For example: ...
3
by: buzz2050 | last post by:
Hi all, I am using cURL for the first time. I need to login to a site and my cURL code to do the same is as follows: //curlScript.php <?php function getContent($url, $referer,...
0
by: coolatt | last post by:
Hi All, I have some some web applications (Roundcube Webmail, phpBB forum & Wiki) which i want to integrate into a CMS like Drupal or Joomla. All the web applications run on the same server and...
0
by: Alex T | last post by:
Here is my code: What it has to do is convert the webpage source into a .txt file, but unfortunately it is causing exceptions. In case anyone asks, I am using Visual C++ 2010 Express. Why is it...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.