Sign in to follow this  

A looping problem..

This topic is 4837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Argh me mateys, yet another loop problem that the heathen unwashed masses have come up against, and failed to beat! Anyway, I'm having a small problem. You see, I need my program as it is right now, when a certain function is called (parseFile()), to open up a file (PacMap.map), read until it hits this string here: ===, then do it again, until it nits the next one of those strings, and then one more time. However, anytime I try to introduce a loop into this, it hangs, and I can't figure out why... Terribly annoying.. Anyway, here's the applicable code, although knowing me, it's probably not enough... Without further ado... Main.ccp
void parseFile()
{
    int threeTimes = 0;
    bool loopVar = true;
    char buffer[128];
    char encrypt;
    char tempEncrypt;
    char hashA;
    char hashB;
    
    ifstream fMapEncIn("PacMap.map");
    ofstream fMapEncOut("PacMap.dec");
    
    while (loopVar == true)
    {
        fMapEncIn.getline(buffer, 127, '\n');
        if (buffer == "===")
        {
            threeTimes++;
        }
        if (threeTimes == 3)
        {
            loopVar = false;
        }
    }
    
    while (fMapEncIn.get(encrypt))
    {
        if (fMapEncIn.peek() == '\n')
        {
            fMapEncIn.ignore(1, '\n');
            fMapEncOut << "\n";
        }
        else
        {
            tempEncrypt = encrypt ^ encryptHash;
            fMapEncOut << tempEncrypt;
        }
    }
    
}



And here's the file that gets read (encrypted).. PacMap.map:
Ò>
===
Œ
Õ
L“
t
/»çêÉo,w½ÄlŠ×þþ*<span class="cpp-number">9</span>>óáÏX¸
æŠÀ˜ÃÆÓ|\ÂÞË.#ÐU|=ü:w«
?z>•¢,b-fˆ-‡ò#$*•õD
ØÜÇ<span class="cpp-number">9</span>
H
†F¨Õû%;OŠ*8R°‰È¼`H'ß
Jí öV©#Χd¯>&ÿÈ/ž
===
·ž¨ú'PÕ<span class="cpp-number">2</span>š
WŠGY.u'†·H
ÁÛŒ ˆ÷½¤ë†
+@+súM&
ç<span class="cpp-number">6</span>¦Ÿ%ÈîÞj
ßò#m[¼ÿÈà
v‹ÅÁüM&
3vT1ã·.±
Væs¸Øè³
YÝÁÛ-j6s
$ú<span class="cpp-number">6</span>®)žâ¦
œØãe?HÇ
^Ü
ødj³Ú¼
˜X^ç
Ÿ#<span class="cpp-number">6</span>’
h‹AÀ¶ˆÏR¶â
‹l{ǧrä¬v
(§ÕP
¾¡øª
ðó–Í:}Êå
œŽ¬W×Â㎍ú
 ŠhÃqÆ‹òÐ
ƒY-ô
¹Ò™N>(sÄ
#¬õõ¢‘QŸ
>.$<span class="cpp-number">3</span>®$l‹
eL3¶¥ÐÃ^I,
ÀI‚¾·o_¯Û
ß<span class="cpp-number">3</span>ãsýS…
`týÀÉ°Ž©&¹
p÷ú@
ûôH;–´ë
}YS¤»R
»ú¢ö†y
dkM˜áàª
ª‚¾ÅÄ
ݻK
_@Ü·<span class="cpp-number">6</span>‹py
<span class="cpp-number">3</span>ÜlI¼•#ØÛñ
IሜÖrÉ»Õ÷
-:y‹ÿòiK-
õ2C~‡
ç*
ð+<span class="cpp-number">4</span>bç<span class="cpp-number">45</span>þ
w5ϤÂÛu×µe
±vÀ¬â+×
>$A*°
8JßCL¿Œ>n
ž‘™„%DS?
le[¥AM„ó‘
ÖüE cÔ=fe
"ä,¶\ðöõ%
FXrT­áÂ-Ƶ
===
Ò¼§¿³¸§¿³¿§»ÔÒ¹§¸³½§¸³¼§¿ÔÒº§¼³º§¸³»§¸ÔÒ¿§º³¿§¿³¼§¹ÔÒ¿§¹³»§º³¹§½
Ò¹§¹³¿§¼³»§¼ÔÒº§¿³½§¿³¼§¿ÔÒ¿§½³¹§¿³º§ºÔÒ½§¹³¸§½³½§ºÔÒ¹§¹³»§¼³¿§¸
Ò¿§¿³»§¼³»§ºÔÒ¹§¿³¸§¼³»§»ÔÒ»§»³¸§¹³½§¼ÔÒº§½³º§»³¹§¸ÔÒ½§¿³¼§¹³¹§¿
Ò¹§»³º§»³¹§½ÔÒ¿§¹³º§»³»§¼ÔÒº§¹³º§¹³½§ºÔÒ¹§»³¹§»³½§¸ÔÒ»§¹³¹§º³¿§»
Ò¼§¼³»§¸³º§¸ÔÒ¼§º³º§¸³¸§¸ÔÒ¸§º³º§»³¿§»ÔÒ»§¿³¸§º³¿§½ÔÒ½§º³½§»³¼§¼
Ò¿§¹³¼§¹³¹§½ÔÒ½§»³¸§¸³¿§¿ÔÒ¼§»³»§º³¿§¸ÔÒ»§º³¸§½³º§¼ÔÒ»§¼³¹§º³¹§¿
Ò»§¼³»§¼³¹§»ÔÒ¸§»³»§º³º§¿ÔÒ¿§¸³¹§¸³¿§»ÔÒ¸§»³º§º³»§¿ÔÒ½§¿³¼§¸³¸§º
Ò¼§¸³¹§½³¹§»ÔÒº§¿³º§»³¿§¼ÔÒº§½³¼§»³¿§ºÔÒ¼§º³¸§¹³¹§¸ÔÒ¼§¿³¼§¿³¿§¹
Ò»§¼³¿§¸³¿§¼ÔÒ¿§º³¿§¸³¸§¼ÔÒ¸§¸³¹§»³½§ºÔÒ½§¿³½§½³¹§ºÔÒ»§¿³¸§¹³»§¸
Ò¹§º³¿§¹³¿§»ÔÒ»§¹³¿§¹³¿§ºÔÒº§¸³¿§¹³¹§»ÔÒ»§¸³»§¸³¿§»ÔÒ¼§º³¹§¿³¹§¿
Ò½§¹³¼§º³¿§¹ÔÒº§º³º§¸³º§¹ÔÒ¿§»³½§¿³½§¸ÔÒ¼§½³º§¿³º§¿ÔÒ»§¹³¼§½³¸§º
Ò¿§»³½§¼³½§¼ÔÒ¸§¿³¸§¸³¹§¼ÔÒ½§¸³¼§½³¸§¸ÔÒ¸§½³¸§º³¸§»ÔÒ½§¸³»§¸³»§½
Ò¸§½³¼§¹³½§¿ÔÒº§»³¹§»³º§ºÔÒ¸§»³¹§¼³¼§¿ÔÒ¿§¼³¿§½³¿§¼ÔÒ¼§¸³½§¸³¸§¸
Ò¹§¿³¼§¼³½§ºÔÒº§»³º§¸³¿§¼ÔÒ½§¹³º§½³º§ºÔÒ¹§¼³½§½³»§ºÔÒ½§¸³¿§»³¹§½
Ò¸§º³¼§½³º§»ÔÒ½§¸³½§½³½§¸ÔÒ¹§º³»§½³¼§¿ÔÒ¼§¸³¹§¼³º§½ÔÒº§»³¿§¿³¹§¼
Ò»§º³»§¿³»§»ÔÒ¼§¼³»§»³º§½ÔÒº§½³º§º³¼§»ÔÒ¼§º³½§º³¿§¿ÔÒº§¸³¿§»³½§¸
Ò¼§½³º§»³¹§ºÔÒ¼§¹³¿§¿³½§¼ÔÒ»§¼³»§¸³»§¼ÔÒ¼§¿³¼§¸³»§¿ÔÒ½§¹³¹§¿³º§½
Ò¸§¹³¼§¸³¼§¼ÔÒ¿§½³º§¸³¸§»ÔÒ¹§¿³¼§»³¼§ºÔÒ½§º³½§»³»§½ÔÒ»§¿³¹§¿³»§¹
Ò½§¸³»§¸³½§ºÔÒ¼§¿³¹§¼³½§¸ÔÒ½§¹³¼§¸³»§ºÔÒ¼§¹³¹§½³º§¿ÔÒ½§½³¹§»³¹§¹
Ò»§º³º§½³¼§¼ÔÒ»§¸³»§»³¸§¹ÔÒ¿§»³½§¸³¼§½ÔÒº§¹³¹§¼³¼§¿ÔÒ¸§¹³¿§º³¹§½
Òº§¸³¼§¹³½§ºÔÒ¼§¼³¿§¿³¸§¼ÔÒ¿§º³¿§¹³½§¼ÔÒ»§½³»§½³¿§¹ÔÒ¹§º³¿§¸³½§¼
Ò¹§½³¼§¸³½§¿ÔÒ»§¹³¸§¼³¸§¹ÔÒ¸§½³¿§½³º§¹ÔÒ¿§¿³¼§¿³¸§¼ÔÒ½§½³½§¿³¿§¸
Òº§¹³¿§¹³¼§¸ÔÒ½§¸³¼§»³¿§¹ÔÒ¸§½³º§»³º§¸ÔÒ½§º³¿§¹³º§¸ÔÒ¸§»³»§º³¹§¿
Ò¼§»³½§»³¿§½ÔÒ¿§¹³½§»³¹§»ÔÒ½§½³¹§¼³º§¼ÔÒº§¸³½§¸³½§¹ÔÒ¼§»³¸§½³¹§¸
Ò¼§½³¹§º³¿§½ÔÒ¸§¹³»§¿³½§»ÔÒ¼§»³¿§»³¿§¿ÔÒ½§»³¿§¹³¼§»ÔÒº§¿³¼§¿³¸§»
Ò¹§½³¼§»³½§¸ÔÒ¿§½³¹§º³º§¸ÔÒ¸§¿³¸§¹³¼§½ÔÒ¹§½³½§¿³¿§¸ÔÒ¸§¿³¿§º³»§½
Ò¹§¿³º§½³¿§ºÔÒ¸§º³º§½³¸§»ÔÒ½§½³¹§¼³¿§½ÔÒ¼§¹³¹§¸³¼§»ÔÒ¿§½³¹§»³º§¿
Ò»§¼³º§½³º§¸ÔÒº§¸³»§º³¸§¸ÔÒ¸§¿³¼§¸³º§¼ÔÒ½§¼³º§¸³¹§ºÔÒ¼§¿³½§º³¼§»
Òº§½³¹§¿³¹§¼ÔÒ¿§¹³¸§½³½§ºÔÒº§¸³¹§½³¹§¿ÔÒ¹§¹³¹§º³¼§¸ÔÒ»§º³¿§½³¹§¸
Ò»§»³¿§¹³½§¿ÔÒ»§¹³»§»³¼§¿ÔÒ¹§¼³½§»³½§¿ÔÒ¹§º³»§»³»§»ÔÒº§¹³¹§º³¹§º
Ò»§»³¹§½³¿§»ÔÒ¹§¿³¿§»³¸§¼ÔÒ¼§¸³½§½³¸§ºÔÒ»§º³¹§¼³¸§½ÔÒ¸§¸³½§¸³»§»
Ò¹§¹³¼§¹³¼§¸ÔÒ½§º³½§½³¿§¼ÔÒ»§º³»§¸³½§ºÔÒ¹§¹³¸§½³¸§ºÔÒ½§¹³¿§½³¼§¼
Ò¿§¿³¼§»³º§¼ÔÒ»§»³¹§¸³»§»ÔÒ½§¿³º§º³¹§»ÔÒº§¼³½§¼³¿§¼ÔÒ¼§½³¼§¸³½§»
Ò¹§¹³¿§¹³¼§¸ÔÒ½§¼³¸§¼³¿§¼ÔÒ¹§¿³º§º³º§¿ÔÒ¸§¸³¼§¼³¼§¸ÔÒ¿§½³½§¸³¸§º
Ò¸§¿³¹§½³¼§ºÔÒ¸§»³¼§¹³¼§»ÔÒ¹§¼³¸§¸³¸§ºÔÒ½§½³½§½³¿§¹ÔÒº§½³»§¿³¿§º
Ò¹§¼³¸§¼³º§ºÔÒ½§¹³¼§¹³º§½ÔÒ»§¼³¼§¹³¿§¼ÔÒ¿§¸³¹§¸³»§ºÔÒ¿§¿³»§¼³¿§¸
Ò»§º³¸§º³¸§»ÔÒ¸§»³½§½³¼§¸ÔÒ¿§¹³½§¹³¹§¼ÔÒº§»³½§»³»§ºÔÒ¼§½³¿§¿³º§½
Ò¿§¹³¼§¿³¸§»ÔÒ¸§»³»§»³º§ºÔÒ»§¼³»§¿³¹§¹ÔÒ¹§¹³¼§»³¿§¼ÔÒ¹§½³¹§½³¼§¼
Ò¸§¼³»§¸³¼§»ÔÒ¸§¼³½§¼³¹§»ÔÒ¸§»³¸§¿³½§¸ÔÒ¼§¹³»§¿³º§¼ÔÒº§½³¿§¿³¼§»
Ò¿§¼³»§½³¼§ºÔÒ½§¸³»§¿³º§¼ÔÒ½§¸³¼§¿³¿§½ÔÒ¹§¹³º§º³¿§¿ÔÒº§¿³¹§»³¿§½
Ò¿§¹³¹§¿³¸§¸ÔÒ½§º³º§¹³½§¹ÔÒ¸§¸³º§¹³¼§ºÔÒ»§¹³»§¸³¼§¼ÔÒ»§½³¼§¹³¸§½
Ò¹§¹³»§»³º§ºÔÒ¿§½³¹§¹³¹§»ÔÒ½§»³¸§¿³»§¿ÔÒ½§º³¸§¸³»§»ÔÒ¸§¹³»§»³¿§º
Ò¹§½³½§º³º§¿ÔÒ¿§¹³¸§¸³º§¹ÔÒ»§º³¿§¸³¿§¿ÔÒ¸§¿³¹§½³¿§½ÔÒ¼§º³¸§¹³¸§¿
Ò¿§»³»§º³¿§¸ÔÒ¿§¸³¿§½³¿§¿ÔÒ¸§º³¼§¼³¸§¿ÔÒº§½³½§»³º§½ÔÒ»§¹³¸§»³º§¹
Òº§»³½§¹³¿§¼ÔÒ½§¼³»§¸³½§¼ÔÒ»§½³º§¿³¿§½ÔÒ»§¼³»§¿³¹§¼ÔÒ»§»³º§¿³¸§¸
Ò½§»³»§¿³½§¹ÔÒ¹§»³»§º³º§¿ÔÒ¸§»³»§½³º§½ÔÒº§¹³º§¸³»§½ÔÒ¼§¹³¸§¼³»§½
Òº§¹³¿§¿³»§½ÔÒ¼§½³¿§º³¿§¼ÔÒ½§¿³»§¿³½§ºÔÒ¼§¿³¼§½³½§½ÔÒº§¹³¿§¿³¸§¿
Ò¿§»³¹§º³¿§¸ÔÒ¿§¿³¸§º³¸§ºÔÒ»§¿³¸§¿³¸§½ÔÒ»§¹³»§½³¹§¿ÔÒ¸§½³¿§¿³º§¼
Ò½§¹³¸§½³¹§ºÔÒº§¿³¼§»³¿§¼ÔÒ¿§¿³¿§¼³¸§¿ÔÒ¿§¹³¿§½³º§¸ÔÒ¼§»³¼§»³¸§¼
Ò¼§¿³¼§º³¹§ºÔÒ¹§¹³º§¹³»§¹ÔÒ»§¸³¼§¿³¼§½ÔÒ¹§¸³¿§¹³¸§ºÔÒº§¼³¿§¹³¹§½
Ò¹§¼³¹§½³¸§¿ÔÒ½§»³¿§»³¹§ºÔÒ¿§¸³¹§¹³º§½ÔÒº§¸³½§»³¼§¼ÔÒº§»³º§»³»§¿
Ò½§¼³¹§½³¸§¸ÔÒ¹§¸³½§¹³½§½ÔÒ»§½³¿§»³º§¸ÔÒ½§¼³¼§¿³¹§¸ÔÒ¹§¹³»§»³¼§»
Ò»§º³¼§¼³¿§¼ÔÒ»§¿³¼§½³¹§½ÔÒ¿§»³¼§¼³¿§¹ÔÒ½§¹³½§¿³»§ºÔÒ¹§¼³½§¼³¹§º
Ò¼§º³º§»³¸§½ÔÒ¹§¹³¸§¸³¿§¿ÔÒ¹§¼³¼§¼³¼§½ÔÒ¼§¹³»§»³¿§½ÔÒ¸§¼³½§¼³º§¹
Ò¿§½³¸§º³½§¼ÔÒ¼§»³¼§¹³¿§¿ÔÒ¸§½³¹§¿³½§¼ÔÒ¹§¸³¼§¹³¼§ºÔÒº§½³¸§¹³¸§¼
Ò¹§¿³¿§¸³½§¿ÔÒ»§½³»§½³¸§¿ÔÒ»§½³¼§¹³»§½ÔÒº§¿³º§»³¸§¸ÔÒ»§»³¸§¹³¿§¸
Òº§º³¸§»³¸§½ÔÒ¹§º³º§¿³¹§¹ÔÒº§¼³»§½³¼§»ÔÒ¿§º³º§¹³¸§»ÔÒ»§¹³¸§¼³º§¼
Ò¼§»³¿§¼³½§ºÔÒ¼§¹³½§¹³¸§¹ÔÒ¸§º³½§½³¿§¹ÔÒ¿§»³»§¸³¹§¹ÔÒ¸§½³º§¸³¹§¸
Ò½§¿³¿§¼³¹§ºÔÒ¿§½³¸§»³½§»ÔÒ¹§»³¹§º³¹§½ÔÒ¹§½³¼§¼³º§¸ÔÒ¼§º³¿§¼³¼§¼
Ò¼§½³½§¹³º§ºÔÒ¿§¿³¹§º³¼§½ÔÒ»§¸³¹§¹³»§¿ÔÒ¹§¼³¸§½³¼§¸ÔÒº§»³½§º³º§¼
Ò¿§¿³¹§¿³¹§¿ÔÒº§¸³¹§¹³º§¼ÔÒ¼§½³¸§º³¼§¸ÔÒ½§½³½§½³¿§¸ÔÒº§½³¼§º³¼§º
Ò¹§½³¸§¸³¹§½ÔÒ¹§½³»§¸³º§¸ÔÒ¼§º³¿§¸³¸§¹ÔÒ¹§¸³¿§½³½§½ÔÒº§»³¹§»³½§¹
Òº§¹³¸§½³¹§ºÔÒ¹§¼³¼§º³¿§¿ÔÒ¸§¿³¿§¿³º§¹ÔÒ¿§¼³¸§¼³»§½ÔÒ»§¸³¸§¸³¹§¹
Ò¼§¿³¸§¸³½§¼ÔÒº§¸³¹§º³¹§¹ÔÒ¸§»³¼§º³½§¸ÔÒ¹§º³½§½³½§¸ÔÒ¼§º³º§¹³º§»
Ò¸§»³½§¹³¸§»ÔÒ½§º³¼§»³¸§¸ÔÒ¸§º³¼§¼³¼§¹ÔÒ¹§¿³¹§º³»§¼ÔÒ¼§º³¼§»³»§»
Ò½§º³½§º³º§¿ÔÒ¹§º³º§¿³¼§¼ÔÒº§º³¼§¼³»§¹ÔÒ»§¿³¸§¹³º§¿ÔÒ»§¹³¼§º³¹§¿
Ò¸§º³¿§¸³º§½ÔÒ¹§¼³º§¿³¼§¸ÔÒ½§½³¸§¿³¿§½ÔÒ½§¹³½§¿³¼§»ÔÒº§¼³»§»³½§½
Ò¿§º³»§¹³½§½ÔÒ½§¿³¼§»³¹§¸ÔÒ½§¿³¹§¿³»§ºÔÒº§»³½§¹³½§»ÔÒ¼§¹³¹§¹³¼§¸
Òº§º³¸§¸³¿§¼ÔÒº§»³º§¹³¼§½ÔÒ¹§»³¹§¹³¼§¿ÔÒ¿§½³¹§º³½§¹ÔÒ¸§»³½§¼³¸§¸
Ò½§¹³»§¸³¹§½ÔÒ¼§¿³¸§º³¹§»ÔÒ¿§¸³¹§¹³¼§»ÔÒ»§¸³¿§¸³»§¹ÔÒ¿§¸³½§¼³º§½
Ò½§¸³½§¼³¹§¼ÔÒ¼§»³¸§¿³»§½ÔÒ½§¸³»§½³º§¸ÔÒ¿§¿³¼§¸³»§¸ÔÒ¸§¼³½§½³¸§¸
Ò¼§»³¸§¹³¹§¼ÔÒº§¼³¹§»³º§½ÔÒ»§¿³¸§º³»§½ÔÒ¸§¸³¼§º³¼§½ÔÒ½§¹³½§»³¼§º
Ò¿§¹³º§º³º§¿ÔÒ¿§¿³¿§¿³¿§½ÔÒ¼§¿³¸§¹³º§¸ÔÒ¼§»³»§¸³½§¹ÔÒ»§¹³º§¼³¿§¸
Ò¼§¿³¸§½³¹§½ÔÒ¹§½³¸§¿³¹§»ÔÒ¼§¼³¼§»³¸§½ÔÒ»§¹³¼§½³¸§»ÔÒ¿§½³¸§»³¿§½
Ò¹§½³¼§º³¼§¹ÔÒ½§»³º§¿³¿§ºÔÒ¼§»³»§º³½§¸ÔÒ¿§¼³½§»³º§¿ÔÒ»§¹³¸§º³¸§¼
Ò¿§¼³½§»³¼§»ÔÒ¼§¹³»§¸³¼§¹ÔÒ¹§½³¼§½³º§ºÔÒ»§º³¹§¸³º§¹ÔÒº§»³½§»³º§¹
Ò¼§¹³½§º³º§»ÔÒ¹§½³½§¸³º§¼ÔÒ½§º³»§¼³¹§¿ÔÒº§¹³¼§»³¹§¼ÔÒ¹§º³½§¼³¿§¸
Ò¼§¹³»§º³¼§»ÔÒº§¸³¼§¼³º§¿ÔÒ»§¹³¿§¿³¹§¹ÔÒ¸§»³¸§¹³º§¸ÔÒ»§½³»§¸³¸§½
Ò¿§¹³¿§»³½§½ÔÒº§º³¼§¹³¼§»ÔÒ½§¹³¼§½³¼§»ÔÒ»§¸³½§½³º§»ÔÒ½§¼³¿§¼³¼§¼
Ò»§¸³¿§»³º§¸ÔÒº§º³¿§¸³¸§¿ÔÒ½§¸³¿§¼³¸§¸ÔÒ¹§¿³º§»³¸§»ÔÒ»§¸³¸§¹³¿§½
Òº§º³»§½³º§»ÔÒ¼§º³½§¿³½§¹ÔÒ¹§¹³¸§½³º§½ÔÒ¼§º³¸§»³¿§¹ÔÒ¹§º³¹§¼³¸§¸
Ò¿§¹³¹§º³¿§¹ÔÒ¿§¸³»§¼³º§½ÔÒ¼§»³¸§¼³»§»ÔÒ¼§»³»§»³»§¼ÔÒ½§¿³¼§»³¹§¿
Ò½§¹³»§¼³¼§½ÔÒ¹§»³½§¸³¹§¹ÔÒ¼§¹³º§½³½§½ÔÒ»§»³¸§¹³»§¼ÔÒ½§¿³¹§»³¸§º
Òº§¼³¸§¸³¹§½ÔÒ¸§º³¼§º³º§¸ÔÒ¼§¼³¿§½³¹§»ÔÒ¼§¿³½§¼³½§¼ÔÒ¹§º³º§¸³½§½
Ò¼§¹³¸§¹³¼§½ÔÒ¿§¹³¿§½³¸§¼ÔÒ¼§º³½§¹³¸§¿ÔÒ¹§¸³½§½³¼§½ÔÒ¸§¸³¹§º³º§¼
Ò¿§¼³º§¼³¸§¸ÔÒ¼§¸³¹§»³¿§¸ÔÒ¼§¿³º§¿³¼§ºÔÒ¿§¿³¹§½³½§ºÔÒ¹§¹³¹§¹³¼§¿
Ò¼§¸³¼§¹³¸§ºÔÒ¸§¼³¼§¸³¼§¸ÔÒº§¹³¿§¸³»§¼ÔÒ½§¸³¿§¸³¿§¹ÔÒ¸§¸³º§¹³¼§¿
Òº§¸³¸§¼³»§»ÔÒ½§»³º§º³»§½ÔÒ¹§»³½§¸³¼§¸ÔÒ¿§º³½§¿³¿§¸ÔÒº§»³¿§¿³¼§¿
Òº§½³¹§¼³º§¸ÔÒº§¹³¿§¹³»§¿ÔÒº§¹³¿§¼³»§¿ÔÒ»§»³º§¸³º§½ÔÒ¹§¼³¹§¹³½§¼
Òº§¼³º§º³»§½ÔÒ¸§»³º§¹³»§¸ÔÒ¹§½³¼§½³º§¼ÔÒ½§¿³¸§¸³»§¼ÔÒ¹§¸³¼§¸³¿§¼
Ò¸§¼³º§¼³¼§¼ÔÒ¿§½³¹§¹³¼§¹ÔÒ½§¿³º§½³»§»ÔÒ¸§¼³¸§¿³¸§ºÔÒ¼§¼³º§¼³º§¿
Ò»§º³¸§¼³¸§»ÔÒº§¸³»§¸³»§¹ÔÒ»§¿³»§º³¸§»ÔÒ¹§¹³½§¸³½§¸ÔÒ¹§½³º§¹³½§¹
Ò»§»³¹§½³¼§¿ÔÒ½§º³»§»³¼§¸ÔÒº§¼³¸§¹³½§ºÔÒ¸§½³¹§»³¹§¼ÔÒ¼§»³º§º³½§¹
Ò¸§½³»§¹³º§¸ÔÒ¿§¼³¿§¼³º§¿ÔÒ½§¼³º§¸³¿§¼ÔÒ¿§¿³»§»³¿§¿ÔÒ½§¹³¿§º³¼§º
Ò½§»³»§¹³»§¿ÔÒ¿§¼³º§¸³»§½ÔÒ¹§¿³»§»³»§½ÔÒ¿§½³º§¿³¸§¸ÔÒ¼§º³¸§¼³¼§»
Òº§½³¸§¹³¿§¿ÔÒ½§º³¹§½³¿§¹ÔÒ¼§¸³¹§¿³»§¹ÔÒ¹§½³¹§º³»§¿ÔÒ¿§¸³¸§º³¸§¸
Ò¸§½³º§»³¿§¿ÔÒ»§¿³½§½³º§¸ÔÒ»§¿³»§¿³¿§»ÔÒº§¹³»§¼³¹§»ÔÒº§º³¹§¸³½§¸
Ò¸§»³¿§»³½§ºÔÒ»§½³¹§½³º§¼ÔÒ¸§º³¼§¸³¼§¸ÔÒ»§º³½§¼³½§»ÔÒ¿§»³½§¹³¸§¿
Ò¼§½³»§½³º§¼ÔÒ¼§¹³»§¿³¿§¹ÔÒ¹§¿³¸§½³¹§¹ÔÒ¸§¼³¸§¸³¹§»ÔÒ¸§½³¿§¹³¸§½
Ò½§º³¼§º³½§¸ÔÒ¼§½³½§¼³¼§½ÔÒ¿§»³½§¸³½§»ÔÒ¹§º³º§¼³¸§ºÔÒº§¸³º§»³º§¿
Ò¹§¿³¼§¿³¸§ºÔÒº§»³¿§¹³¸§»ÔÒ¸§¿³¹§¿³¸§¸ÔÒ½§¼³½§¹³¸§¿ÔÒ¹§º³¿§½³¸§¸
Ò¹§º³½§»³º§¹ÔÒ¹§¹³¿§¸³¸§½ÔÒ¿§¿³»§¼³»§¸ÔÒ»§»³¸§¹³½§ºÔÒ¼§¿³»§¿³»§»
Ò»§½³¿§»³¼§¿ÔÒ¸§¹³½§¹³¹§»ÔÒ»§»³¼§¸³º§¿ÔÒ½§¸³¹§¿³»§¿ÔÒ¸§¼³¼§¸³º§½
Ò¿§½³¸§¹³»§¸ÔÒº§»³¸§¹³¼§¿ÔÒ¹§¿³¹§¼³½§¸ÔÒ¸§»³¿§¼³¼§¹ÔÒ»§½³¸§º³¿§¸
Ò¼§º³¿§¼³º§¸ÔÒ¹§º³¼§º³½§¹ÔÒ½§½³¸§º³¼§¿ÔÒ¿§¹³½§»³»§¼ÔÒ»§¿³¼§»³½§¿
Ò½§¿³º§º³¿§»ÔÒ¼§¸³»§¹³¸§ºÔÒ½§»³¼§»³¸§ºÔÒ¿§¹³¼§¼³¼§¿ÔÒ¼§¿³½§º³¸§»
Ò¸§¿³¸§¿³¿§¼ÔÒ½§¸³¼§¹³¹§ºÔÒ½§º³¼§¿³¹§¿ÔÒ»§»³¹§¹³¼§¸ÔÒ¸§¼³¿§½³¼§¼
Ò½§º³½§¹³¼§¼ÔÒ»§½³¼§½³¸§¿ÔÒ¹§½³¹§¹³»§¿ÔÒ»§½³¹§»³º§¸ÔÒ»§½³º§»³¿§½
Ò¸§½³½§¸³½§»ÔÒ¹§º³¸§¹³»§¸ÔÒ¸§¸³¿§¹³¼§¸ÔÒ½§¿³¿§»³¼§¸ÔÒ¸§»³½§¹³¼§¿
Ò¼§¿³¿§¹³º§¿ÔÒ½§¿³¹§¼³¿§¿ÔÒ»§¼³»§»³¸§½ÔÒº§½³¿§¼³¸§ºÔÒ¸§º³½§»³¸§¼
Ò¿§º³¹§º³»§¹ÔÒ¸§º³¿§¸³¸§¸ÔÒ¸§¼³»§½³¿§¼ÔÒ½§»³¹§»³¹§¿ÔÒ½§»³¹§¼³»§»
Ò½§½³»§»³¼§¼ÔÒ¹§¿³º§»³¿§¹ÔÒ¼§¹³º§¿³º§¼ÔÒ¹§¹³º§¼³¸§¸ÔÒ»§¿³¿§¼³»§»
Ò½§¿³¼§¹³¹§»ÔÒ¹§»³»§¼³¼§¿ÔÒ¿§¼³¸§¼³½§½ÔÒº§¿³½§¸³¹§¹ÔÒ»§¹³¹§¿³»§¼
Ò¸§»³»§¼³¹§ºÔÒ¸§½³»§¹³½§¹ÔÒ¼§¼³¹§¸³º§ºÔÒ¸§½³¸§½³¿§¼ÔÒ½§¼³¹§º³¹§¸
Ò¿§¿³¼§¸³¿§¹ÔÒ»§¼³º§¿³¿§¸ÔÒ¹§¼³¸§¿³¸§½ÔÒ¹§¸³º§¼³»§¿ÔÒ¼§¸³º§¸³¼§»
Òº§º³¹§¸³½§½ÔÒ¹§¹³»§½³¹§¸ÔÒ¸§¿³º§¹³»§¸ÔÒº§»³»§¼³¹§ºÔÒ¹§º³¼§»³º§»
Ò¿§¹³¿§¿³¼§¸ÔÒº§¸³½§º³º§¹ÔÒº§º³º§¿³º§¿ÔÒ¸§½³½§¹³»§¹ÔÒ¼§¿³½§¹³¼§»
Ò½§¼³»§¸³º§¹ÔÒ¹§¼³¿§¹³½§¿ÔÒ»§½³½§»³¹§½ÔÒº§¸³¸§¹³½§¼ÔÒ¸§º³¹§»³»§¼
Ò»§½³¼§¹³¼§¼ÔÒ¹§º³»§¸³¼§½ÔÒ¼§¿³¿§º³º§½ÔÒº§¸³½§¹³¼§¹ÔÒ¼§¼³½§½³¿§»
Ò½§»³¸§¿³¼§¿ÔÒ¼§½³½§¼³º§ºÔÒ¹§¿³¹§¿³º§»ÔÒ»§¿³½§¹³º§¹ÔÒ½§¼³¼§º³¸§¸
Òº§½³»§¿³º§¿ÔÒ»§¼³½§½³¿§ºÔÒ¿§½³¸§¿³¼§ºÔÒ½§½³¿§¼³¸§½ÔÒ½§¹³»§¹³»§¿
Ò½§½³»§½³»§¸ÔÒ½§»³¼§»³¼§¿ÔÒ¹§¸³¹§½³º§¸ÔÒ¿§½³¸§¼³¿§¹ÔÒº§»³¿§»³¸§½
Ò½§¿³¹§º³»§ºÔÒº§¸³¹§½³¼§¸ÔÒ¸§¹³½§»³¸§½ÔÒ»§¿³¼§¼³¼§¸ÔÒ¸§¹³¹§»³½§¿
Ò¹§¹³¿§¹³»§¿ÔÒ¸§¸³¸§»³º§»ÔÒ¼§¹³º§¿³¼§¹ÔÒ½§¿³½§¹³¿§ºÔÒº§º³¸§¸³¹§º
Ò¿§¼³½§¹³º§¿Ô


Anyone help would be greatly appreciated, and rewarded with an e-cookie :) Thanks in advance!

Share this post


Link to post
Share on other sites
you can't compare strings like this:

if ( buffer == "===" )

it needs to be:

if ( !strcmp(buffer,"===") )

either that or use std::string... but the above should fix it. you also need to handle the case where there are never "===" strings in your files. then it wouldn't be hanging it would just be telling you that it never found the "===" string. there should be an additional check in your while loop that looks something like this:

while (loopVar == true && !fMapEncIn.eof() )

-me

Share this post


Link to post
Share on other sites

if (buffer == "===")
{
threeTimes++;
}



buffer is declared as a "char [128]". when you say buffer == "===" you are testing the pointer value (IE the adddress that it points to in memory), not the actual value. You need to use strcmp() function (in the standard library, or you can write your own) for C-style strings, or use std::string which overloads the == operator in order to use it.

Hope this helps.

Share this post


Link to post
Share on other sites
I can’t read you encrypted file, but I think the problem is the way you are reading the characters from the file. You should look up lexical analysis for shits and giggles. It may help you out a lot.

You should read one character at a time. Then, jump to some different code that find is the next character is something you need. That is a horrible explanation of syntax directed translation and transition diagrams, sorry.

You should use a switch statement while reading characters. If the character read is the one you want then you mode to the next case. Or, you invoke an error routine or kick out the input stream. Like this


// NOTE: This code is not optimized with any buffer techniques
//

FILE* pFile = NULL;
int nTimes = 0,
nState = 0,
nCh = 0;

/* Open file for reading */

while ( nTimes != 3 )
{
nCh = fgetc( pFile );

switch ( nState )
{
case 0:
if ( nCh == EOF )
/* Exit out of here */
else if ( nCh == ‘=’ )
nState = 1;
else
; // do nothing
break;

case 1:
if ( nCh == ‘=’ )
nState = 2;
else
nState = 0; // did not find the second ‘=’
break;

case 3:
if ( nCh == ‘=’ )
{
// BINGO!
nTimes++;
nState = 0;
}
else
nState = 0; // did not find the third‘=’
break;
};
}



That should do the trick :) Still though, you should check into what I told you too. You may find some useful information on those topics that could help you out with future projects. You also need to change the way you compare strings. Your buffer == ‘===’ is comparing the pointer, not the contents of it

Now where is my damn cooke!?

Share this post


Link to post
Share on other sites
OK, I'm afraid I'm still lost...
Anyway, I've tried all the methods mentioned, but anytime I use any sort of loop, it hangs. It runs just fine without the loop (if running fine can be defined as running, even if it's not doing what I need it to do...), but as soon as I put any sort of 'for' or 'while' loop in there, bamph, it hangs. I'm at a loss for what to do.. If anyone has any idea why this might be happening, I would really appreciate the help. Oh, BTW, the function is called from inside the Windows Procedure, if that's of any help.

Thanks

Share this post


Link to post
Share on other sites

This topic is 4837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this