Click here to Skip to main content
15,905,967 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionClicks on taskbar Pin
Abhi Lahare30-Jul-07 23:03
Abhi Lahare30-Jul-07 23:03 
AnswerRe: Clicks on taskbar Pin
Abdellatif_El_Khlifi12-Aug-07 16:12
Abdellatif_El_Khlifi12-Aug-07 16:12 
Questionchanging the position of CFileDialog Pin
iayd30-Jul-07 22:09
iayd30-Jul-07 22:09 
AnswerRe: changing the position of CFileDialog Pin
prasad_som30-Jul-07 22:23
prasad_som30-Jul-07 22:23 
QuestionRe: changing the position of CFileDialog Pin
iayd31-Jul-07 1:17
iayd31-Jul-07 1:17 
AnswerRe: changing the position of CFileDialog Pin
prasad_som31-Jul-07 2:45
prasad_som31-Jul-07 2:45 
AnswerRe: changing the position of CFileDialog Pin
David Crow31-Jul-07 2:43
David Crow31-Jul-07 2:43 
QuestionRe: changing the position of CFileDialog Pin
iayd31-Jul-07 3:22
iayd31-Jul-07 3:22 
AnswerRe: changing the position of CFileDialog Pin
David Crow31-Jul-07 3:26
David Crow31-Jul-07 3:26 
AnswerRe: changing the position of CFileDialog Pin
Mark Salsbery31-Jul-07 7:52
Mark Salsbery31-Jul-07 7:52 
QuestionRegarding Macros Pin
janadhana30-Jul-07 22:04
janadhana30-Jul-07 22:04 
AnswerRe: Regarding Macros Pin
Don Box30-Jul-07 22:29
Don Box30-Jul-07 22:29 
QuestionRe: Regarding Macros Pin
CPallini30-Jul-07 22:36
mveCPallini30-Jul-07 22:36 
AnswerRe: Regarding Macros Pin
CPallini30-Jul-07 22:35
mveCPallini30-Jul-07 22:35 
QuestionTo assign string from String table to a controll's caption at design time? Pin
Mushtaque Nizamani30-Jul-07 22:03
Mushtaque Nizamani30-Jul-07 22:03 
AnswerRe: To assign string from String table to a controll's caption at design time? Pin
codeII30-Jul-07 22:26
codeII30-Jul-07 22:26 
GeneralRe: To assign string from String table to a controll's caption at design time? Pin
Mushtaque Nizamani30-Jul-07 22:33
Mushtaque Nizamani30-Jul-07 22:33 
GeneralRe: To assign string from String table to a controll's caption at design time? Pin
codeII30-Jul-07 23:58
codeII30-Jul-07 23:58 
GeneralRe: To assign string from String table to a controll's caption at design time? Pin
Nelek31-Jul-07 0:46
protectorNelek31-Jul-07 0:46 
JokeRe: To assign string from String table to a controll's caption at design time? [modified] Pin
CPallini30-Jul-07 22:40
mveCPallini30-Jul-07 22:40 
QuestionTaskbarnotifier Pin
vicky0000030-Jul-07 21:41
vicky0000030-Jul-07 21:41 
AnswerRe: Taskbarnotifier Pin
Nelek30-Jul-07 21:45
protectorNelek30-Jul-07 21:45 
AnswerRe: Taskbarnotifier Pin
ashukasama30-Jul-07 21:49
ashukasama30-Jul-07 21:49 
AnswerRe: Taskbarnotifier Pin
Nishad S30-Jul-07 21:52
Nishad S30-Jul-07 21:52 
QuestionParasing website data : intermitten rubbish characters retrived Pin
awah30-Jul-07 21:28
awah30-Jul-07 21:28 
Parasing website data : intermitten rubbish characters retrived

hi, i am making a program to parse data from website, to do that i need to download the file

Step1: download file

CString Data;<br />
//CString Buffer;<br />
	DeleteUrlCacheEntry(url);// delete the old stupid cache<br />
<br />
HINTERNET IntOpen = ::InternetOpen("Sample", LOCAL_INTERNET_ACCESS, NULL, 0, 0);<br />
HINTERNET handle = ::InternetOpenUrl(IntOpen, url, NULL, NULL, NULL, NULL);<br />
HANDLE hFile	= ::CreateFile("c:\\index.txt", GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);<br />
 <br />
char Buffer[1024];<br />
DWORD dwRead =0;<br />
while(::InternetReadFile(handle, Buffer, sizeof(Buffer), &dwRead) == TRUE)<br />
{<br />
	if ( dwRead == 0) <br />
	 break;<br />
	DWORD dwWrite = 0;<br />
	::WriteFile(hFile, Buffer, dwRead, &dwWrite, NULL);<br />
	Data+=Buffer;<br />
}<br />
<br />
 ::CloseHandle(hFile);<br />
::InternetCloseHandle(handle);<br />


the Cstring "Data" contains the website in a plain text
step2 : parse the data using brackets
because a lot of data in within <> brackets, this can be used to reference the desired data

<br />
// this function look for the text and removes "bracket_distance" number of <>, then return the result <br />
// eg. "dsfsd<><><><>6.35<>", item = dsfsd, bracket_distance = 4<br />
CString Mydialog::Parse_Backets(CString file_string, CString item, int bracket_distance)<br />
{<br />
	file_string.ReleaseBuffer();<br />
<br />
	int start_index;<br />
	int end_index;<br />
	start_index = file_string.Find(item);<br />
	if(start_index == -1)<br />
	{<br />
		CString error_string = "Error";<br />
		error_flag = 1;<br />
		return error_string;<br />
	}<br />
	for(int i =0; i <bracket_distance; i++)<br />
	{<br />
		start_index = file_string.Find(">",start_index)+1;<br />
	}<br />
	end_index = file_string.Find("<",start_index) - 1;<br />
	file_string=file_string.Mid(start_index, end_index-start_index+1  );<br />
	return file_string;<br />
}



now the problem is once in a while i get rubbish characters. Like the actual value when i browse to the website, should be 0.55 , i get 0.aj5m5, or even 0.1595

the website is http://stquote.sgx.com/live/st/STStock.asp?stk=G

does anyone knows how to solve this problem?
using:
- mfc
- VC6.0

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.