<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>DevX.com Forums - C++</title>
		<link>http://forums.devx.com</link>
		<description>C++ programming</description>
		<language>en</language>
		<lastBuildDate>Sun, 22 Nov 2009 04:25:31 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://forums.devx.com/images/misc/rss.jpg</url>
			<title>DevX.com Forums - C++</title>
			<link>http://forums.devx.com</link>
		</image>
		<item>
			<title>simulating alt+2 (keypad) combination</title>
			<link>http://forums.devx.com/showthread.php?t=173417&amp;goto=newpost</link>
			<pubDate>Fri, 20 Nov 2009 20:58:16 GMT</pubDate>
			<description><![CDATA[I am trying to print the corresponding Unicode character for alt+2 to the Windows console window. (the console doesn't display the character, but should display ^B instead)
The following doesn't seem to work. Just prints "2".


Code:
---------
keybd_event(VK_MENU,0 ,0 , 0); //Alt Press

Sleep(10);
keybd_event(VK_NUMPAD2,0, 0 , 0); // 2 Press

Sleep(10);
keybd_event(VK_NUMPAD2,0, KEYEVENTF_KEYUP,0); // 2 Release

Sleep(10);
keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0); // Alt Release

Sleep(10);
---------
Neither does this work. Just prints "2", again.


Code:
---------
	INPUT inputs = {0}; 
	inputs.type = INPUT_KEYBOARD; 

	KEYBDINPUT ki = {0}; 
	ki.wVk = VK_LMENU;

	inputs.ki = ki;
	SendInput(1, &inputs, sizeof(INPUT)); // Left alt

	ki.wVk = VK_NUMPAD2;
	inputs.ki = ki;
	SendInput(1, &inputs, sizeof(INPUT)); // Numpad 2

	ki.dwFlags = KEYEVENTF_KEYUP;

	ki.wVk = VK_NUMPAD2;
	inputs.ki = ki;
	SendInput(1, &inputs, sizeof(INPUT)); // Numpad 2

	ki.wVk = VK_LMENU;
	inputs.ki = ki;
	SendInput(1, &inputs, sizeof(INPUT)); // Left alt
---------
]]></description>
			<content:encoded><![CDATA[<div>I am trying to print the corresponding Unicode character for alt+2 to the Windows console window. (the console doesn't display the character, but should display ^B instead)<br />
The following doesn't seem to work. Just prints &quot;2&quot;.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">keybd_event(VK_MENU,0 ,0 , 0); //Alt Press<br />
<br />
Sleep(10);<br />
keybd_event(VK_NUMPAD2,0, 0 , 0); // 2 Press<br />
<br />
Sleep(10);<br />
keybd_event(VK_NUMPAD2,0, KEYEVENTF_KEYUP,0); // 2 Release<br />
<br />
Sleep(10);<br />
keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0); // Alt Release<br />
<br />
Sleep(10);</code><hr />
</div>Neither does this work. Just prints &quot;2&quot;, again.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">&nbsp; &nbsp; &nbsp; &nbsp; INPUT inputs = {0}; <br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.type = INPUT_KEYBOARD; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; KEYBDINPUT ki = {0}; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_LMENU;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Left alt<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_NUMPAD2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Numpad 2<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.dwFlags = KEYEVENTF_KEYUP;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_NUMPAD2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Numpad 2<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_LMENU;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Left alt</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>kangekraam</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173417</guid>
		</item>
		<item>
			<title>Writing a code parser</title>
			<link>http://forums.devx.com/showthread.php?t=173384&amp;goto=newpost</link>
			<pubDate>Mon, 16 Nov 2009 13:59:56 GMT</pubDate>
			<description><![CDATA[I am trying to write a code parser in C++.  I just need to be able to read file that i give (with the tokens already done) and to output to another file.

I have written the scanner/analyser already so i've got my tokens that i need to parse.

I think the trouble i've got is being able to loop through each token and looking at tokens that are in front.

I wanted to do a while loop while the last token wasn't read but it doesn't work and i've tried using a for loop but i can't access tokens ahead that don't exist (obvioulsy).

Is there a better way I can access each element so i can perform the right action without a for loop?


Code:
---------
for(int a=0, b=0; a < kinds.size(), b < spellings.size(); a++, b++)
{
	//while(!kinds.back())
	//{
		if(kinds.at(a) == "INT")
		{
			if(kinds.at(a+2) == "LPARN")
				cout << "%function" << spellings.at(b) << spellings.at(b+1) << endl;
			if(kinds.at(a+2) == "SEMI" || kinds.at(a+2) == "COMMA" || kinds.at(a+2) == "RPARN")
				cout << "%variable" << spellings.at(b) << spellings.at(b+1) << endl;
		}
		
		if(kinds.at(a) == "VOID" && kinds.at(a+2) == "LPARN")
		{
			cout << "%procedure" << spellings.at(b+1) << endl;
		}
		
		if(kinds.at(a) == "LBRACE")
		{
			cout << "%begin" << endl;
		}

		if(kinds.at(a) == "RBRACE")
		{
			cout << "%end" << endl;
		}
		
		if(kinds.at(a) == "IF")
		{
			cout << "%if" << endl;
		}
		
		if(kinds.at(a) == "RETURN")
		{
			cout << "%return ";
			if(kinds.at(a+1) == "NUMBER")
				cout << "%num" << spellings.at(a+1) << endl;
		}
		
		if(kinds.at(a) == "IDENTIFIER" || kinds.at(a+1) == "ASSIGN")
		{
			// this is where i get an error that the program has terminated in an unusual way
			//if(kinds.at(a+2) == "LPARN" && kinds.at(a+3) == "RPARN")
				//cout << "%assign " << spellings.at(a) << "%call" << spellings.at(a+2) << spellings.at(a+3) << endl;

		}

	//}
}
---------
]]></description>
			<content:encoded><![CDATA[<div>I am trying to write a code parser in C++.  I just need to be able to read file that i give (with the tokens already done) and to output to another file.<br />
<br />
I have written the scanner/analyser already so i've got my tokens that i need to parse.<br />
<br />
I think the trouble i've got is being able to loop through each token and looking at tokens that are in front.<br />
<br />
I wanted to do a while loop while the last token wasn't read but it doesn't work and i've tried using a for loop but i can't access tokens ahead that don't exist (obvioulsy).<br />
<br />
Is there a better way I can access each element so i can perform the right action without a for loop?<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">for(int a=0, b=0; a &lt; kinds.size(), b &lt; spellings.size(); a++, b++)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; //while(!kinds.back())<br />
&nbsp; &nbsp; &nbsp; &nbsp; //{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(kinds.at(a) == &quot;INT&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(kinds.at(a+2) == &quot;LPARN&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;%function&quot; &lt;&lt; spellings.at(b) &lt;&lt; spellings.at(b+1) &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(kinds.at(a+2) == &quot;SEMI&quot; || kinds.at(a+2) == &quot;COMMA&quot; || kinds.at(a+2) == &quot;RPARN&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;%variable&quot; &lt;&lt; spellings.at(b) &lt;&lt; spellings.at(b+1) &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(kinds.at(a) == &quot;VOID&quot; &amp;&amp; kinds.at(a+2) == &quot;LPARN&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;%procedure&quot; &lt;&lt; spellings.at(b+1) &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(kinds.at(a) == &quot;LBRACE&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;%begin&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(kinds.at(a) == &quot;RBRACE&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;%end&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(kinds.at(a) == &quot;IF&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;%if&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(kinds.at(a) == &quot;RETURN&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;%return &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(kinds.at(a+1) == &quot;NUMBER&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;%num&quot; &lt;&lt; spellings.at(a+1) &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(kinds.at(a) == &quot;IDENTIFIER&quot; || kinds.at(a+1) == &quot;ASSIGN&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // this is where i get an error that the program has terminated in an unusual way<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if(kinds.at(a+2) == &quot;LPARN&quot; &amp;&amp; kinds.at(a+3) == &quot;RPARN&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //cout &lt;&lt; &quot;%assign &quot; &lt;&lt; spellings.at(a) &lt;&lt; &quot;%call&quot; &lt;&lt; spellings.at(a+2) &lt;&lt; spellings.at(a+3) &lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //}<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>AdRock</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173384</guid>
		</item>
		<item>
			<title>VC++ - In need of books on Advanced Debugging Techniques</title>
			<link>http://forums.devx.com/showthread.php?t=173378&amp;goto=newpost</link>
			<pubDate>Sun, 15 Nov 2009 16:47:08 GMT</pubDate>
			<description><![CDATA[Hi All,
 I primarily work on Microsoft Technologies using VC++. Could someone suggest me useful books covering 
1) "advanced debugging techniques" and 
2) performance engineering:  WinDbg/SOS, CLR Profiler, Visual Studio Profiler? 

    Any suggestion / help is appreciated. 

    Thanks in advance.

N. Murali Mohan]]></description>
			<content:encoded><![CDATA[<div>Hi All,<br />
 I primarily work on Microsoft Technologies using VC++. Could someone suggest me useful books covering <br />
1) &quot;advanced debugging techniques&quot; and <br />
2) performance engineering:  WinDbg/SOS, CLR Profiler, Visual Studio Profiler? <br />
<br />
    Any suggestion / help is appreciated. <br />
<br />
    Thanks in advance.<br />
<br />
N. Murali Mohan</div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>Murali</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173378</guid>
		</item>
		<item>
			<title>Looping through the windows registry using RegEnumKeyEx till the leaves</title>
			<link>http://forums.devx.com/showthread.php?t=173377&amp;goto=newpost</link>
			<pubDate>Sun, 15 Nov 2009 12:59:03 GMT</pubDate>
			<description><![CDATA[Hi all,

I am trying to write code to loop through the windows registry till i find the leaf , meaning the 
key value pair exists . Each time i get the key , i want to know whether it is parent of some key-value pair.
If yes , loop through its children till the point where a key comes which has no child. I tried writing the program on my own
using RegEnumKeyEx , The key structure is given below.

If you type *"regedit"*, you get the following template...


Code:
---------

	System
	   Select
		Current - 2
		Default - "Key"
		Known	- "Key2"
		LastError - "Key"
	   Select1
		Current - 2
		Default - "Key"
		Known	- "Key2"
		LastError - "Key"
	   Select2
		Current - 2
		Default - "Key"
		Known	- "Key2"
		LastError - "Key"
---------
In the above tree , i want to loop through subkeys of "System" like Select , Select1 and Select2
and loop through the key value pair as given above.I have written the code as below for retrieving
subkeys.


Code:
---------
void QueryKey(HKEY hKey) 
{ 
    TCHAR    achKey[500];   // buffer for subkey name
    DWORD    cbName;                   // size of name string 
    TCHAR    achClass[MAX_PATH] = TEXT("");  // buffer for class name 
    DWORD    cchClassName = MAX_PATH;  // size of class string 
    DWORD    cSubKeys=0;               // number of subkeys 
    DWORD    cbMaxSubKey;              // longest subkey size 
    DWORD    cchMaxClass;              // longest class string 
    DWORD    cValues;              // number of values for key 
    DWORD    cchMaxValue;          // longest value name 
    DWORD    cbMaxValueData;       // longest value data 
    DWORD    cbSecurityDescriptor; // size of security descriptor 
    FILETIME ftLastWriteTime;      // last write time 
 
    DWORD i, retCode; 
 
    TCHAR  achValue[MAX_VALUE_NAME]; 
    DWORD cchValue = MAX_VALUE_NAME; 
 
    // Get the class name and the value count. 
    retCode = RegQueryInfoKey(
        hKey,                    // key handle 
        achClass,                // buffer for class name 
        &cchClassName,           // size of class string 
        NULL,                    // reserved 
        &cSubKeys,               // number of subkeys 
        &cbMaxSubKey,            // longest subkey size 
        &cchMaxClass,            // longest class string 
        &cValues,                // number of values for this key 
        &cchMaxValue,            // longest value name 
        &cbMaxValueData,         // longest value data 
        &cbSecurityDescriptor,   // security descriptor 
        &ftLastWriteTime);       // last write time 
 
    // Enumerate the subkeys, until RegEnumKeyEx fails.
    
    if (cSubKeys)
    {
        printf( "\nNumber of subkeys: %d\n", cSubKeys);
		if(cSubKeys!=0)
        for (i=0; i<cSubKeys; i++) 
        { 
            cbName = MAX_KEY_LENGTH;
            retCode = RegEnumKeyEx(hKey, i,
                     achKey, 
                     &cbName, 
                     NULL, 
                     NULL, 
                     NULL, 
                     &ftLastWriteTime); 
            if (retCode == ERROR_SUCCESS) 
            {
                _tprintf(TEXT("(%d) %s\n"), i+1, achKey);

            }
		//Here write a recursive function to loop through the subkeys
        }
    
	} 
	else
	{
		printf("This is a child\n");
	}
 
    // Enumerate the key values. 

    }
}
---------
]]></description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I am trying to write code to loop through the windows registry till i find the leaf , meaning the <br />
key value pair exists . Each time i get the key , i want to know whether it is parent of some key-value pair.<br />
If yes , loop through its children till the point where a key comes which has no child. I tried writing the program on my own<br />
using RegEnumKeyEx , The key structure is given below.<br />
<br />
If you type <b>&quot;regedit&quot;</b>, you get the following template...<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><br />
&nbsp; &nbsp; &nbsp; &nbsp; System<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Select<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Current - 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Default - &quot;Key&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Known&nbsp; &nbsp; &nbsp; &nbsp; - &quot;Key2&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LastError - &quot;Key&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Select1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Current - 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Default - &quot;Key&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Known&nbsp; &nbsp; &nbsp; &nbsp; - &quot;Key2&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LastError - &quot;Key&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Select2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Current - 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Default - &quot;Key&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Known&nbsp; &nbsp; &nbsp; &nbsp; - &quot;Key2&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LastError - &quot;Key&quot;</code><hr />
</div>In the above tree , i want to loop through subkeys of &quot;System&quot; like Select , Select1 and Select2<br />
and loop through the key value pair as given above.I have written the code as below for retrieving<br />
subkeys.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">void QueryKey(HKEY hKey) <br />
{ <br />
&nbsp; &nbsp; TCHAR&nbsp; &nbsp; achKey[500];&nbsp;  // buffer for subkey name<br />
&nbsp; &nbsp; DWORD&nbsp; &nbsp; cbName;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // size of name string <br />
&nbsp; &nbsp; TCHAR&nbsp; &nbsp; achClass[MAX_PATH] = TEXT(&quot;&quot;);&nbsp; // buffer for class name <br />
&nbsp; &nbsp; DWORD&nbsp; &nbsp; cchClassName = MAX_PATH;&nbsp; // size of class string <br />
&nbsp; &nbsp; DWORD&nbsp; &nbsp; cSubKeys=0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // number of subkeys <br />
&nbsp; &nbsp; DWORD&nbsp; &nbsp; cbMaxSubKey;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // longest subkey size <br />
&nbsp; &nbsp; DWORD&nbsp; &nbsp; cchMaxClass;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // longest class string <br />
&nbsp; &nbsp; DWORD&nbsp; &nbsp; cValues;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // number of values for key <br />
&nbsp; &nbsp; DWORD&nbsp; &nbsp; cchMaxValue;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // longest value name <br />
&nbsp; &nbsp; DWORD&nbsp; &nbsp; cbMaxValueData;&nbsp; &nbsp; &nbsp;  // longest value data <br />
&nbsp; &nbsp; DWORD&nbsp; &nbsp; cbSecurityDescriptor; // size of security descriptor <br />
&nbsp; &nbsp; FILETIME ftLastWriteTime;&nbsp; &nbsp; &nbsp; // last write time <br />
&nbsp;<br />
&nbsp; &nbsp; DWORD i, retCode; <br />
&nbsp;<br />
&nbsp; &nbsp; TCHAR&nbsp; achValue[MAX_VALUE_NAME]; <br />
&nbsp; &nbsp; DWORD cchValue = MAX_VALUE_NAME; <br />
&nbsp;<br />
&nbsp; &nbsp; // Get the class name and the value count. <br />
&nbsp; &nbsp; retCode = RegQueryInfoKey(<br />
&nbsp; &nbsp; &nbsp; &nbsp; hKey,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // key handle <br />
&nbsp; &nbsp; &nbsp; &nbsp; achClass,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // buffer for class name <br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;cchClassName,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // size of class string <br />
&nbsp; &nbsp; &nbsp; &nbsp; NULL,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // reserved <br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;cSubKeys,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // number of subkeys <br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;cbMaxSubKey,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // longest subkey size <br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;cchMaxClass,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // longest class string <br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;cValues,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // number of values for this key <br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;cchMaxValue,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // longest value name <br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;cbMaxValueData,&nbsp; &nbsp; &nbsp; &nbsp;  // longest value data <br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;cbSecurityDescriptor,&nbsp;  // security descriptor <br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;ftLastWriteTime);&nbsp; &nbsp; &nbsp;  // last write time <br />
&nbsp;<br />
&nbsp; &nbsp; // Enumerate the subkeys, until RegEnumKeyEx fails.<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; if (cSubKeys)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf( &quot;\nNumber of subkeys: %d\n&quot;, cSubKeys);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(cSubKeys!=0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i=0; i&lt;cSubKeys; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cbName = MAX_KEY_LENGTH;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retCode = RegEnumKeyEx(hKey, i,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  achKey, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &amp;cbName, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  NULL, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  NULL, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  NULL, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &amp;ftLastWriteTime); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (retCode == ERROR_SUCCESS) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _tprintf(TEXT(&quot;(%d) %s\n&quot;), i+1, achKey);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Here write a recursive function to loop through the subkeys<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;This is a child\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp;<br />
&nbsp; &nbsp; // Enumerate the key values. <br />
<br />
&nbsp; &nbsp; }<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>rag84dec</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173377</guid>
		</item>
		<item>
			<title>Execute Command As Administrator</title>
			<link>http://forums.devx.com/showthread.php?t=173370&amp;goto=newpost</link>
			<pubDate>Fri, 13 Nov 2009 21:26:04 GMT</pubDate>
			<description><![CDATA[Okay, so I have to execute a batch command on a restricted user's account, however the batch command will not work unless the process has Administrative Privileges.

currently i call the batch command via

Code:
---------
system("command here");
---------
I, as the programmer, know the Administrator user/password on the WinXP machine this is to be executed on.

How can i execute this command/program as an administrator?  I'm thinking about using the
SetThreadToken() function (http://msdn.microsoft.com/en-us/library/aa379590%28VS.85%29.aspx) but I do not know how to construct the token object properly

Thanks,
Philly0494]]></description>
			<content:encoded><![CDATA[<div>Okay, so I have to execute a batch command on a restricted user's account, however the batch command will not work unless the process has Administrative Privileges.<br />
<br />
currently i call the batch command via<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">system(&quot;command here&quot;);</code><hr />
</div>I, as the programmer, know the Administrator user/password on the WinXP machine this is to be executed on.<br />
<br />
How can i execute this command/program as an administrator?  I'm thinking about using the<br />
SetThreadToken() function (<a rel="nofollow" href="http://msdn.microsoft.com/en-us/library/aa379590%28VS.85%29.aspx" target="_blank">http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx</a>) but I do not know how to construct the token object properly<br />
<br />
Thanks,<br />
Philly0494</div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>philly0494</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173370</guid>
		</item>
		<item>
			<title>Mind block: temp object destruction</title>
			<link>http://forums.devx.com/showthread.php?t=173368&amp;goto=newpost</link>
			<pubDate>Fri, 13 Nov 2009 18:41:17 GMT</pubDate>
			<description><![CDATA[I've got a case where I want a class to be used only as a temporary object which completes the action at destruction. (For "complete" think "transmits itself").

So, when is a temporary object destroyed?

Code:
---------
{
    TempClass() << "Stuff"; // here?
    ...
} // here?
---------
]]></description>
			<content:encoded><![CDATA[<div>I've got a case where I want a class to be used only as a temporary object which completes the action at destruction. (For &quot;complete&quot; think &quot;transmits itself&quot;).<br />
<br />
So, when is a temporary object destroyed?<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">{<br />
&nbsp; &nbsp; TempClass() &lt;&lt; &quot;Stuff&quot;; // here?<br />
&nbsp; &nbsp; ...<br />
} // here?</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>hendrixj</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173368</guid>
		</item>
		<item>
			<title>How to Combine Hexadecimal Numbers</title>
			<link>http://forums.devx.com/showthread.php?t=173357&amp;goto=newpost</link>
			<pubDate>Thu, 12 Nov 2009 03:48:38 GMT</pubDate>
			<description>Hello

How do I combine hexadecimal numbers? For example if I have the numbers:

- aa
- 14
- 5d

How can I combine them to get : aa145d ?</description>
			<content:encoded><![CDATA[<div>Hello<br />
<br />
How do I combine hexadecimal numbers? For example if I have the numbers:<br />
<br />
- aa<br />
- 14<br />
- 5d<br />
<br />
How can I combine them to get : aa145d ?</div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>gretty</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173357</guid>
		</item>
		<item>
			<title>Adding to vector</title>
			<link>http://forums.devx.com/showthread.php?t=173343&amp;goto=newpost</link>
			<pubDate>Mon, 09 Nov 2009 23:40:28 GMT</pubDate>
			<description><![CDATA[I've written some code that reads in a file line by line, splits all lines into words and adds the words to a vector.

I need to call my function that splits a word with puncatutation into serarate tokens and add them to a vector so for example a word like they're would be split into:


---Quote---
they
'
re
---End Quote---
I can split the line into words but the function call i don't think is working as the vector is empty


Code:
---------
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <sstream>
#include <stdio.h>

using namespace std;

vector<string> SplitString (string aString)
{
	vector<string> vec;
	char * cstr, *p;
	
	//string str ("Please split this phrase into tokens");
	
	string str = aString;
	
	cstr = new char [str.size()+1];
	strcpy (cstr, str.c_str());
	
	// cstr now contains a c-string copy of str
	
	p=strtok (cstr," ");
	while (p!=NULL)
	{
	vec.push_back(p);
	p=strtok(NULL," ");
	}
	
	delete[] cstr;
	return vec;
}

std::vector<std::string> SplitOnPunct(std::string const& str,std::string const& punct )
{
    std::vector<std::string> vec1;

    if (str.length() == 0) return vec1;

    std::string::size_type pos, end;

    for (pos = 0; pos != std::string::npos; pos = end)
    {
        end = str.find_first_of(punct, pos);

        if (end == pos && ++end == str.size()) end = std::string::npos;

        vec1.push_back(str.substr(pos, end - pos));
    }

    return vec1;
}

int main()
{
	int i;
	int b=0;
	vector <string> vec1;
	
	string line,com;
	
	ifstream myFile("scan.cm"); 
	
	if (! myFile)
	{
		std::cout << "Error opening output fle"  << endl;
		return -1;
	}
	
	while( getline( myFile, line ) )
	{
		b++;
		
		//check if the current line is a comment
		if(line[0] =='/' && line[1] == '*')
			continue;
		if(line[0] =='*')
			continue;
		if(line[0] =='*' && line[1] == '/')
			continue;
		if(line.empty())
			continue;
		
		size_t pos;
		com = "//";
	
		pos= line.find(com);
						
		if(pos != string::npos)
		{
			int len = line.size();
			
			line.erase(pos, (len-pos));
		}
	
		std::vector<std::string> vec = SplitString(line);
		
		for (std::vector<std::string>::size_type a = 0; a < vec.size(); ++a)
		{
			cout << vec.at(a) << endl; //outputs all words in vector
			
                        // this is where i call the function to split the word and it should add to another vector
                        std::vector<std::string> vec1 = SplitOnPunct(vec.at(a), "+-*/<>{()};,");
		}
		
		std::cout << "LINE: " << b << endl;
		
		cout << vec1.size() << endl; //outputs 0
		
	}

	myFile.close();

	return 0;
}
---------
]]></description>
			<content:encoded><![CDATA[<div>I've written some code that reads in a file line by line, splits all lines into words and adds the words to a vector.<br />
<br />
I need to call my function that splits a word with puncatutation into serarate tokens and add them to a vector so for example a word like they're would be split into:<br />
<br />
<div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="3" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				they<br />
'<br />
re
			
			<hr />
		</td>
	</tr>
	</table>
</div>I can split the line into words but the function call i don't think is working as the vector is empty<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;fstream&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;vector&gt;<br />
#include &lt;cstring&gt;<br />
#include &lt;string&gt;<br />
#include &lt;sstream&gt;<br />
#include &lt;stdio.h&gt;<br />
<br />
using namespace std;<br />
<br />
vector&lt;string&gt; SplitString (string aString)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; vector&lt;string&gt; vec;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char * cstr, *p;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //string str (&quot;Please split this phrase into tokens&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; string str = aString;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cstr = new char [str.size()+1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcpy (cstr, str.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; // cstr now contains a c-string copy of str<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; p=strtok (cstr,&quot; &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (p!=NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; vec.push_back(p);<br />
&nbsp; &nbsp; &nbsp; &nbsp; p=strtok(NULL,&quot; &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; delete[] cstr;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return vec;<br />
}<br />
<br />
std::vector&lt;std::string&gt; SplitOnPunct(std::string const&amp; str,std::string const&amp; punct )<br />
{<br />
&nbsp; &nbsp; std::vector&lt;std::string&gt; vec1;<br />
<br />
&nbsp; &nbsp; if (str.length() == 0) return vec1;<br />
<br />
&nbsp; &nbsp; std::string::size_type pos, end;<br />
<br />
&nbsp; &nbsp; for (pos = 0; pos != std::string::npos; pos = end)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; end = str.find_first_of(punct, pos);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (end == pos &amp;&amp; ++end == str.size()) end = std::string::npos;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; vec1.push_back(str.substr(pos, end - pos));<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; return vec1;<br />
}<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int b=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; vector &lt;string&gt; vec1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; string line,com;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream myFile(&quot;scan.cm&quot;); <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (! myFile)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout &lt;&lt; &quot;Error opening output fle&quot;&nbsp; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; while( getline( myFile, line ) )<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //check if the current line is a comment<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(line[0] =='/' &amp;&amp; line[1] == '*')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(line[0] =='*')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(line[0] =='*' &amp;&amp; line[1] == '/')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(line.empty())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; size_t pos;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; com = &quot;//&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos= line.find(com);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(pos != string::npos)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int len = line.size();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line.erase(pos, (len-pos));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::vector&lt;std::string&gt; vec = SplitString(line);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (std::vector&lt;std::string&gt;::size_type a = 0; a &lt; vec.size(); ++a)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; vec.at(a) &lt;&lt; endl; //outputs all words in vector<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // this is where i call the function to split the word and it should add to another vector<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::vector&lt;std::string&gt; vec1 = SplitOnPunct(vec.at(a), &quot;+-*/&lt;&gt;{()};,&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout &lt;&lt; &quot;LINE: &quot; &lt;&lt; b &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; vec1.size() &lt;&lt; endl; //outputs 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; myFile.close();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>AdRock</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173343</guid>
		</item>
		<item>
			<title><![CDATA[Can't catch this exception]]></title>
			<link>http://forums.devx.com/showthread.php?t=173336&amp;goto=newpost</link>
			<pubDate>Mon, 09 Nov 2009 11:50:46 GMT</pubDate>
			<description><![CDATA[Hi,

I am getting an unhandled exception in some code that I'm working on.  I have put a try... catch(...) around the code but I still get an unhandeled exception message pop up (this is on Windows with Visual Studio 2008).

Using the debugger I get -

Unhandled exception at 0xblahblah in fred.exe: 0xC0000005: Access violation reading location 0x00000000.

Looking up the stack trace to the function where I'm tryring to catch it, the debugger shows I'm within the try section.

Why can't I catch it?

Thanks.

Peter.]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am getting an unhandled exception in some code that I'm working on.  I have put a try... catch(...) around the code but I still get an unhandeled exception message pop up (this is on Windows with Visual Studio 2008).<br />
<br />
Using the debugger I get -<br />
<br />
Unhandled exception at 0xblahblah in fred.exe: 0xC0000005: Access violation reading location 0x00000000.<br />
<br />
Looking up the stack trace to the function where I'm tryring to catch it, the debugger shows I'm within the try section.<br />
<br />
Why can't I catch it?<br />
<br />
Thanks.<br />
<br />
Peter.</div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>PeterS2</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173336</guid>
		</item>
		<item>
			<title>Skipping rest of line on comment</title>
			<link>http://forums.devx.com/showthread.php?t=173333&amp;goto=newpost</link>
			<pubDate>Sun, 08 Nov 2009 23:27:13 GMT</pubDate>
			<description><![CDATA[I need help with a section of code.

I am reading a file which i want to skip comments.  I can skip comments which start with /* etc but i need to skip comments that start with //

This is ok if the comments sart at the beginning of the line but if they are half way through the line it causes a problem.

what it does is add to a vector each word of a string so i want it to read the line, add each word to a vector until it reaches a //

I can add to the vector fine but i need to be able to skip the line once it reaches a //


Code:
---------
while( getline( myFile, line ) )
{		
	string value;
	istringstream iss(line);
	std::ostringstream p;
	
	while (iss >> value)
	{	
		//check if the current line is a comment
		if(line[0] =='/' && line[1] == '*')
			continue;
		else if(line[0] =='*')
			continue;
		else if(line[0] =='*' && line[1] == '/')
			continue;
		
                //this is where i need to do a check
		while(!value.find_first_of("//",0))
		{
			//Do code here
		}
	}
}
---------
]]></description>
			<content:encoded><![CDATA[<div>I need help with a section of code.<br />
<br />
I am reading a file which i want to skip comments.  I can skip comments which start with /* etc but i need to skip comments that start with //<br />
<br />
This is ok if the comments sart at the beginning of the line but if they are half way through the line it causes a problem.<br />
<br />
what it does is add to a vector each word of a string so i want it to read the line, add each word to a vector until it reaches a //<br />
<br />
I can add to the vector fine but i need to be able to skip the line once it reaches a //<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">while( getline( myFile, line ) )<br />
{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; string value;<br />
&nbsp; &nbsp; &nbsp; &nbsp; istringstream iss(line);<br />
&nbsp; &nbsp; &nbsp; &nbsp; std::ostringstream p;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; while (iss &gt;&gt; value)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //check if the current line is a comment<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(line[0] =='/' &amp;&amp; line[1] == '*')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(line[0] =='*')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(line[0] =='*' &amp;&amp; line[1] == '/')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //this is where i need to do a check<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(!value.find_first_of(&quot;//&quot;,0))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Do code here<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>AdRock</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173333</guid>
		</item>
		<item>
			<title>String as name</title>
			<link>http://forums.devx.com/showthread.php?t=173330&amp;goto=newpost</link>
			<pubDate>Sun, 08 Nov 2009 02:08:28 GMT</pubDate>
			<description><![CDATA[Hi, just had a quick question:

If I defined a string: char a[] = "Hello";

And then I defined an integer: int b = 5;

How could I define an integer whose name was the string a, without directly doing int Hello = 5, but instead using a.

Thanks for this!]]></description>
			<content:encoded><![CDATA[<div>Hi, just had a quick question:<br />
<br />
If I defined a string: <font color="RoyalBlue">char </font>a[] = &quot;Hello&quot;;<br />
<br />
And then I defined an integer: <font color="royalblue">int </font>b = 5;<br />
<br />
How could I define an integer whose name was the string a, without directly doing <font color="royalblue">int </font>Hello = 5, but instead using a.<br />
<br />
Thanks for this!</div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>ah605</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173330</guid>
		</item>
		<item>
			<title>Getting string out of a 2D vector into a string variable</title>
			<link>http://forums.devx.com/showthread.php?t=173328&amp;goto=newpost</link>
			<pubDate>Sat, 07 Nov 2009 15:21:50 GMT</pubDate>
			<description><![CDATA[I have a 2D vector and I need to assign each value of the inner vector to a string.

I am having problems getting what is in the vector into a string variable

If anyone could please help I would be very happy as I can't fix this problem


Code:
---------
for ( vector< vector< string > > :: size_type i = 0, size = info.size(); i < size; ++i)
{
	for ( vector < string > :: size_type j = 0, length = info[i].size(); j < length; ++j)
	{
		//check to see if the inner vectors are empty
		if(info[i].size() > 1)
			
			//std::string strd = info[i][j].at(j);
			//cout<<strd.c_str()<<endl;
			//if(strd == "int") {cout << "INT: ";}
			cout << info[i][j] << endl;
	}
	cout << endl;
}
---------
]]></description>
			<content:encoded><![CDATA[<div>I have a 2D vector and I need to assign each value of the inner vector to a string.<br />
<br />
I am having problems getting what is in the vector into a string variable<br />
<br />
If anyone could please help I would be very happy as I can't fix this problem<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">for ( vector&lt; vector&lt; string &gt; &gt; :: size_type i = 0, size = info.size(); i &lt; size; ++i)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; for ( vector &lt; string &gt; :: size_type j = 0, length = info[i].size(); j &lt; length; ++j)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //check to see if the inner vectors are empty<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(info[i].size() &gt; 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //std::string strd = info[i][j].at(j);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //cout&lt;&lt;strd.c_str()&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if(strd == &quot;int&quot;) {cout &lt;&lt; &quot;INT: &quot;;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; info[i][j] &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>AdRock</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173328</guid>
		</item>
		<item>
			<title>how to store data in a folder</title>
			<link>http://forums.devx.com/showthread.php?t=173327&amp;goto=newpost</link>
			<pubDate>Sat, 07 Nov 2009 10:09:09 GMT</pubDate>
			<description>hi..i am writng a program.....i have collected a lot of information(name,hobbies etc.....) of about a hundred students in my school.......i have also stored their photographs in .jpeg format.........i am using Dev c++ and windows xp..........i want to store all this info + photos in a single file....how do i go about it............i started programmin a few days ago......so whatever u explain...please explain it in lay mans terms..........i dont want the entire code....but parts of the code ....it wud be great if you could explain it a bit n could give sources for me study it in greater detail</description>
			<content:encoded><![CDATA[<div>hi..i am writng a program.....i have collected a lot of information(name,hobbies etc.....) of about a hundred students in my school.......i have also stored their photographs in .jpeg format.........i am using Dev c++ and windows xp..........i want to store all this info + photos in a single file....how do i go about it............i started programmin a few days ago......so whatever u explain...please explain it in lay mans terms..........i dont want the entire code....but parts of the code ....it wud be great if you could explain it a bit n could give sources for me study it in greater detail</div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>karanmehra18</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173327</guid>
		</item>
		<item>
			<title>NTFS Change Journals</title>
			<link>http://forums.devx.com/showthread.php?t=173320&amp;goto=newpost</link>
			<pubDate>Fri, 06 Nov 2009 09:24:31 GMT</pubDate>
			<description><![CDATA[Hi,

I am new to Windows related Code in C++.

Currently, I wish to monitor my system for the modified files using NTFS Change Journals. I tried to query the Journal data (using DeviceIOControl) and get the modified file details. I need some clarifications regarding the below things.

1. Is there a way to search notifications for particular folder (say only My Documents and My Pictures) or particular fileTypes (say jpg, doc, etc).
2. Is there a way to search only recent modifications (say for the past 1 day or 5 hrs, etc)
3. If my application create journal for a volume and stopped means, then in the next time when it restarted can I monitor the changes during the period when my application was not running. (I tried it , seems I can't do it).
4. If I modify a file present under 'D:/Testing/Test.txt', it seems the usn_record 'ParentFileReferenceNumber' is for D: and the 'FileReferenceNumber' is for the particular file 'Test.txt'. But what I think is the 'ParentFileReferenceNumber' should be for 'D:/Testing' and the 'FileReferenceNumber' should be for 'Test.txt'. For this, I have made CreateFile() for the '\\.\D:' location. Am I do anything wrong.
5. Shall I use fsutil for my purpose.

Could any one please clarify my queries and point me in a correct direction. Also, if possible, please poing me a releveant help document or URL to further proceed.

Thanks in Advance.

Regards,
Shar.]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am new to Windows related Code in C++.<br />
<br />
Currently, I wish to monitor my system for the modified files using NTFS Change Journals. I tried to query the Journal data (using DeviceIOControl) and get the modified file details. I need some clarifications regarding the below things.<br />
<br />
1. Is there a way to search notifications for particular folder (say only My Documents and My Pictures) or particular fileTypes (say jpg, doc, etc).<br />
2. Is there a way to search only recent modifications (say for the past 1 day or 5 hrs, etc)<br />
3. If my application create journal for a volume and stopped means, then in the next time when it restarted can I monitor the changes during the period when my application was not running. (I tried it , seems I can't do it).<br />
4. If I modify a file present under 'D:/Testing/Test.txt', it seems the usn_record 'ParentFileReferenceNumber' is for D: and the 'FileReferenceNumber' is for the particular file 'Test.txt'. But what I think is the 'ParentFileReferenceNumber' should be for 'D:/Testing' and the 'FileReferenceNumber' should be for 'Test.txt'. For this, I have made CreateFile() for the '\\.\D:' location. Am I do anything wrong.<br />
5. Shall I use fsutil for my purpose.<br />
<br />
Could any one please clarify my queries and point me in a correct direction. Also, if possible, please poing me a releveant help document or URL to further proceed.<br />
<br />
Thanks in Advance.<br />
<br />
Regards,<br />
Shar.</div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>Shar</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173320</guid>
		</item>
		<item>
			<title>How to get the representation of ASCII Charcters from a String Array?</title>
			<link>http://forums.devx.com/showthread.php?t=173311&amp;goto=newpost</link>
			<pubDate>Thu, 05 Nov 2009 09:34:40 GMT</pubDate>
			<description><![CDATA[Dear programmer,

I am searching for a way to get the ASCII character representation from a string array. I am doing a project on stacks.

An example:[u]


Code:
---------

string *myArray;
myArray = new string[arraySize];
---------
*Now the above string array consists of characters (e.g: myArray[0] = 1, myArray[1] = *, myArray[2] = 45...etc).

The idea is get the ASCII code of those characters that are stored in the string array.


Code:
---------

int( myArray[0] ); //Will not work as it is an invalid cast.
---------
*If any one can provide me of any ideas, i would be grateful... I am a beginner-to-intermediate C++ programmer. biggrin.gif

Thanks for reading,
My Regards]]></description>
			<content:encoded><![CDATA[<div>Dear programmer,<br />
<br />
I am searching for a way to get the ASCII character representation from a string array. I am doing a project on stacks.<br />
<br />
An example:[u]<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><br />
string *myArray;<br />
myArray = new string[arraySize];</code><hr />
</div>*Now the above string array consists of characters (e.g: myArray[0] = 1, myArray[1] = *, myArray[2] = 45...etc).<br />
<br />
The idea is get the ASCII code of those characters that are stored in the string array.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><br />
int( myArray[0] ); //Will not work as it is an invalid cast.</code><hr />
</div>*If any one can provide me of any ideas, i would be grateful... I am a beginner-to-intermediate C++ programmer. biggrin.gif<br />
<br />
Thanks for reading,<br />
My Regards</div>

]]></content:encoded>
			<category domain="http://forums.devx.com/forumdisplay.php?f=110">C++</category>
			<dc:creator>c-ray</dc:creator>
			<guid isPermaLink="true">http://forums.devx.com/showthread.php?t=173311</guid>
		</item>
	</channel>
</rss>
