Click here to Skip to main content
16,006,768 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalcast string to integer Pin
tbbooher16-Feb-02 17:28
tbbooher16-Feb-02 17:28 
GeneralRe: cast string to integer Pin
Paul M Watt16-Feb-02 17:46
mentorPaul M Watt16-Feb-02 17:46 
GeneralRe: cast string to integer Pin
Shog916-Feb-02 17:47
sitebuilderShog916-Feb-02 17:47 
GeneralRe: cast string to integer Pin
tbbooher16-Feb-02 17:57
tbbooher16-Feb-02 17:57 
GeneralRe: cast string to integer Pin
Paul M Watt16-Feb-02 18:04
mentorPaul M Watt16-Feb-02 18:04 
GeneralRe: cast string to integer Pin
Shog916-Feb-02 18:06
sitebuilderShog916-Feb-02 18:06 
GeneralAlmost There . . . just one more question Pin
tbbooher16-Feb-02 18:22
tbbooher16-Feb-02 18:22 
GeneralHelp me please! Release mode optimizations are screwing up my program! :( Pin
Julia Larson16-Feb-02 16:58
Julia Larson16-Feb-02 16:58 
Hello everyone, I'm desperate.

What is going on with this. In debug mode it behaves correctly,
giving the correct output showing the insertions made into the
string:

C:\PleaseHelpMe>cd debug
C:\PleaseHelpMe\Debug>pleasehelpme
~@~bt~@~ <title>The Title of the Document ~@~et~@~ </title>

C:\PleaseHelpMe\Debug>pleasehelpme
~@~bt~@~ <title>The Title of the Document ~@~et~@~ </title>


But in release mode, nothing happens! No changes are made
to the string. Please help! Cry | :((

C:\PleaseHelpMe\Debug>cd ..
C:\PleaseHelpMe>cd release

C:\PleaseHelpMe\Release>pleasehelpme
<title>The Title of the Document </title>

What is going on? Please help I'm so confused!

Thank you
-Julie


// PleaseHelpMe.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <afx.h>

static TCHAR g_szBeginTitle[] = "~@~bt~@~";
static TCHAR g_szEndTitle[] = "~@~et~@~";

void InsertCode( TCHAR*& pszBuffer, TCHAR* pszKeyWord, bool& bLineChanged )
{
if ( pszBuffer )
{
*pszBuffer = ' ';
pszBuffer++;

while (*pszBuffer != '\0' && *pszKeyWord != '\0' )
{
*pszBuffer = *pszKeyWord;
pszBuffer++;
pszKeyWord++;
}

if ( pszBuffer )
{
*pszBuffer = ' ';
pszBuffer++;
}
bLineChanged = true;
}
}

void MarkHTMLSignificance( CString& strLine )
{
CString strNewLine;

int nLen = strLine.GetLength() + 2;
TCHAR* pszSource = strLine.GetBuffer( nLen );
TCHAR* pszResult = strNewLine.GetBuffer( nLen * 8 );

bool bLineChanged = false;

while (*pszSource != '\0')
{
if ( *pszSource == '<' )
{
LPTSTR pszTest = pszSource + 1;
switch ( *pszTest )
{
case 't': // possibly title
case 'T':
if ( _tcsnicmp( pszTest, _T("title"), 5 ) == 0 )
InsertCode( pszResult, g_szBeginTitle, bLineChanged );
break;
case '/':
pszTest++;
switch( *pszTest )
{
case 't':
case 'T':
if ( _tcsnicmp( pszTest, _T("title"), 5 ) == 0 )
InsertCode( pszResult, g_szEndTitle, bLineChanged );
break;
} // end switch on slash
} // end switch on t, h, b, slash
} // end if < found
*pszResult = *pszSource;
pszSource++;
pszResult++;
} // end while *pszSource != '\0'
*pszResult = *pszSource; // null terminate!!!

strLine.ReleaseBuffer();
strNewLine.ReleaseBuffer();

if ( bLineChanged )
strLine = strNewLine;
}


int main(int argc, char* argv[])
{
CString strHTML = " <title>The Title of the Document</title> \n";

MarkHTMLSignificance( strHTML );

printf( strHTML );

return 0;
}


GeneralRe: Help me please! Release mode optimizations are screwing up my program! :( Pin
Shog916-Feb-02 17:44
sitebuilderShog916-Feb-02 17:44 
GeneralRe: Help me please! Release mode optimizations are screwing up my program! :( Pin
Julia Larson16-Feb-02 18:06
Julia Larson16-Feb-02 18:06 
GeneralRe: Help me please! Release mode optimizations are screwing up my program! :( Pin
Shog916-Feb-02 18:28
sitebuilderShog916-Feb-02 18:28 
GeneralRe: Help me please! Release mode optimizations are screwing up my program! :( Pin
Julia Larson16-Feb-02 18:57
Julia Larson16-Feb-02 18:57 
GeneralRe: Help me please! Release mode optimizations are screwing up my program! :( Pin
Julia Larson16-Feb-02 19:09
Julia Larson16-Feb-02 19:09 
GeneralRe: Help me please! Release mode optimizations are screwing up my program! :( Pin
Shog916-Feb-02 19:39
sitebuilderShog916-Feb-02 19:39 
GeneralRe: Help me please! Release mode optimizations are screwing up my program! :( Pin
Julia Larson16-Feb-02 20:12
Julia Larson16-Feb-02 20:12 
GeneralIt slowly dawns on me Pin
Julia Larson16-Feb-02 19:16
Julia Larson16-Feb-02 19:16 
GeneralCDialogBar Pin
16-Feb-02 16:28
suss16-Feb-02 16:28 
GeneralRe: CDialogBar Pin
Derek Waters17-Feb-02 11:27
Derek Waters17-Feb-02 11:27 
GeneralDrawing Controls Problem Pin
John Clump16-Feb-02 16:13
John Clump16-Feb-02 16:13 
GeneralRe: Drawing Controls Problem Pin
Shog916-Feb-02 16:25
sitebuilderShog916-Feb-02 16:25 
GeneralRe: Drawing Controls Problem Pin
John Clump16-Feb-02 18:00
John Clump16-Feb-02 18:00 
GeneralRe: Drawing Controls Problem Pin
Shog916-Feb-02 18:30
sitebuilderShog916-Feb-02 18:30 
GeneralRe: Drawing Controls Problem Pin
Ravi Bhavnani16-Feb-02 19:19
professionalRavi Bhavnani16-Feb-02 19:19 
GeneralRe: Drawing Controls Problem Pin
John Clump16-Feb-02 19:47
John Clump16-Feb-02 19:47 
GeneralHelp on Designing Tictactoe in VC++ Pin
John Cruz16-Feb-02 15:38
John Cruz16-Feb-02 15:38 

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.