473,320 Members | 1,978 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.

Get content from web file

Hello Programmers,

I try to get my application to work but i have a question!

How can i get content from a file from http.

Eg.
http://test.com/text.txt <-- in this file i have for example a city
name "Copenhagen" this text would i like to get in my c++ application.

Are there some professionals, who can help me with this?

Best Regards
Thusan - Denmark

Aug 14 '07 #1
5 1914
On Aug 14, 4:45 pm, m...@thusan.com wrote:
Hello Programmers,

I try to get my application to work but i have a question!

How can i get content from a file from http.

Eg.http://test.com/text.txt<-- in this file i have for example a city
name "Copenhagen" this text would i like to get in my c++ application.

Are there some professionals, who can help me with this?

Best Regards
Thusan - Denmark
it's a OS's specific question. C++ does not have anything to deal with
http.
For example, for windows there is a header wininet.h that might help.

Aug 14 '07 #2
r
m...@thusan.com wrote:
Hello Programmers,

I try to get my application to work but i have a question!

How can i get content from a file from http.
Use a library like libcurl. Or if you are writing an application with
a GUI toolkit, the toolkit may already have something for handling
HTTP.

Aug 14 '07 #3
It's a application to Windows CE, Have you any code example to how i
can fix this?

This is the code i have now:

// ExampleManualDlg.cpp : implementation file
//
#include <iostream>
#include <sstream>
#include <fstream>
#include "stdafx.h"
#include "ExampleManual.h"
#include "ExampleManualDlg.h"

#include "sdkconstants.h"
#include "TomTomAPI.h"
#include "TomTomGoFileLayer.h"
#include <stdio.h>
#include <string>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define CLIENT_NAME "client"

int res;
CString str;
CString strout;
CTomTomAPI::TError err;
CTomTomAPI::TVersion version;
CTomTomAPI::TGeocodeResult GeoRes;
char *aCity;
char *aStreet;
char *aNumber;
char *aPostCode;

void CExampleManualDlg::OnButtontt()
{

MTomTomCommunicationLayerInterface *comms =
DEFAULT_TRANSPORTATION_LAYER(CLIENT_NAME,
2005,TOMTOM_TCPIP_PORT);
CTomTomAPI api(*comms);

//Read

aCity = "Randers";
aStreet = "Urtevangen";
aNumber = "9";
aPostCode = "8900";

res =
api.NavigateToAddress(&err,&*aCity,&*aStreet,&*aNu mber,&*aPostCode);
res = api.BringNavigatorToForeground(&err);

strout = "";
str.Format(_T("Geocode = %d\r\n"), res);
strout = strout + aStreet + " | " + aNumber + " | " + aPostCode +
" | " + aCity;
m_EditResult.SetWindowText(strout);

delete comms;

}

Aug 15 '07 #4
Hi!

ma**@thusan.com schrieb:
It's a application to Windows CE, Have you any code example to how i
can fix this?

This is the code i have now:

// ExampleManualDlg.cpp : implementation file
[snip]
#include <stdio.h>
prefer <cstdio>
#include <string>

#ifdef _DEBUG
#define new DEBUG_NEW
Don't define keywords to mean something different. Don't "#define new ...".
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define CLIENT_NAME "client"
Why not use a char array here, too? Does the macro further down require
CLIENT_NAME to be a macro?

static char CLIENT_NAME[] = "client";
int res;
CString str;
CString strout;
CTomTomAPI::TError err;
CTomTomAPI::TVersion version;
CTomTomAPI::TGeocodeResult GeoRes;
char *aCity;
char *aStreet;
char *aNumber;
char *aPostCode;
I guess these are not global variables, but members of CExampleManualDlg.
void CExampleManualDlg::OnButtontt()
{

MTomTomCommunicationLayerInterface *comms =
DEFAULT_TRANSPORTATION_LAYER(CLIENT_NAME,
2005,TOMTOM_TCPIP_PORT);
Further down you "delete comms;" which means it is dynamically
allocated. So prefer automatic memory management:

const std::auto_ptr<MTomTomCommunicationLayerInterface>
comms = DEFAULT_TRANSPORTATION_LAYER(CLIENT_NAME,
2005,TOMTOM_TCPIP_PORT);

You will probably need #include <memoryfor auto_ptr.
CTomTomAPI api(*comms);

//Read

aCity = "Randers";
aStreet = "Urtevangen";
aNumber = "9";
aPostCode = "8900";
Notice: string literals contain chars and must not be modified. you
therefore try to declare the variables as "const char *aCity;". But
maybe the "NavigateToAddress" functions does not permit this.
>
res =
api.NavigateToAddress(&err,&*aCity,&*aStreet,&*aNu mber,&*aPostCode);
"&*aCity" is the same as "aCity". Just drop the "&*" part everywhere:
api.NavigateToAddress(&err, aCity, aStreet, aNumber, aPostCode);
res = api.BringNavigatorToForeground(&err);

strout = "";
str.Format(_T("Geocode = %d\r\n"), res);
strout = strout + aStreet + " | " + aNumber + " | " + aPostCode +
" | " + aCity;
m_EditResult.SetWindowText(strout);

delete comms;
When using auto_ptr just drop the "delete comms;". It will be
automatically deleted.

HTH,
Frank
Aug 15 '07 #5
Hi!

I forgot to mention:

ma**@thusan.com schrieb:
strout = "";
str.Format(_T("Geocode = %d\r\n"), res);
strout = strout + aStreet + " | " + aNumber + " | " + aPostCode +
" | " + aCity;
m_EditResult.SetWindowText(strout);
Maybe stringstreams are easier for this:

std::ostringstream stream;
stream
//should not need '\r', but try:
<< "Geocode = " << res << '\n'
<< aStreet << " | "
<< aNumber << " | "
<< aPostCode << " | "
<< aCity
;
m_EditResult.SetWindowText(stream.str().c_str());
you need #include <sstreamand <ostreamfor this.

Frank
Aug 15 '07 #6

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

Similar topics

3
by: mvargasp | last post by:
Hi all, I have a web form which contains a frame, (a form containing a menu on the left and a web form containing a datagrid on the right). Also there is a button (right side) which transforms...
1
by: Alex Nitulescu | last post by:
Hi. First of all, I *HAVE* to express my annoyance with how badly (at least) this content thing is documented in MSDN. There's no head, nor tail to it. Anyway, I have this code in a form named...
2
by: GMK | last post by:
Dear all in my asp.net application i have a text file that is installed with my application on the server. this text file is filled with data through a web interface in my application. i need to...
0
by: Neo | last post by:
Hello: I am receiving a Binary File in a Request from a application. The stream which comes to me has the boundary (Something like "---------------------------390C0F3E0099" without the quotes),...
4
by: Ganesh Muthuvelu | last post by:
Hi STAN, Stan: Thanks for your response to my previous post on reading a XSD file using your article in "https://blogs.msdn.com/stan_kitsis/archive/2005/08/06/448572.aspx". it works quite well...
0
by: philip20060308 | last post by:
Hi all, Has anyone ever seen Python 2.4.1's httplib choke when reading chunked content? I'm using it via urrlib2, and I ran into a particular server that returns something that httplib doesn't...
7
by: Water Cooler v2 | last post by:
I know what it is, and yet the knowledge of what a CMS is, is so vague that I find myself asking this question every now and then. I've googled and read the resources too. However, the knowledge is...
0
by: newsgroups.jd | last post by:
Thanks for any help in advance... Little background first. I have a report application that creates a flash file for each day of the year. I want to place that file in a content page without...
7
by: xkeops | last post by:
Thinking of creating a website, most of the pages will have a general toolbar menu, a content and a footer. The content will be the only one who's gonna change but the rest (header,footer) will...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
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...
1
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.