Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my program printing out the null termination character?
    primarykey
    data
    text
    <p>When I run this, it will SOMETIMES print out a null termination character. Most of the time it will, and probably 1/5 times it will print just the characters.</p> <pre><code>void cryptogram::Encrypt(){ cout&lt;&lt;"encrypt"&lt;&lt;endl; char Alphabet[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; fin.open("original.txt"); cout&lt;&lt;"file opened"; if(!fin) { cout&lt;&lt;"No file exists"&lt;&lt;endl;; }else{ while(fin&gt;&gt;tempS){ len=tempS.length(); int a=0; for(int j=0;j&lt;len;j++){ for(a;a&lt;=26;a++){ tempS[j]=toupper(tempS[j]); if(tempS[j]!=Alphabet[a]){//while two characters arent equal //if the characters arent equal...a is incremented, to see if the character from the word is equal to the next letter in the alphabet }else{ cout&lt;&lt;Crypto[a]; //crypto is an array of char filled with letters that are used to encrypt the message if(j!=len){ //if the word still has more characters j++; a=0; }else{ //if the word is done being scanned cout&lt;&lt;" "; } } } } } } } </code></pre> <p>So that's it and this is the corresponding EXPECTED output that is printed SOMETIMES</p> <blockquote> <p>xvk bkikhxlr wggbtfkj wiylekgbdhx wjjm hko wigbtubxt xvk iwhj uedjkm glctb gvrmdiwhj iebbdielmeggtbx ctb xvtmk gbtubxvk wjjdxdthgbtubodll khvxvk imkbfdik xt xvk bkudth whj gbtfdjk hko tgxdthm whj tggtbxehdxdkm ctb mxejkhxmibdzdhtltur whj pemxdik mxejdkm mxdh cok wbk wlmt gbkgctb cteb hko zdh cgvrmdikjeiwhj qdhkmdtlturzzkjdydtivkzdmxbrw zdh zdjjlkkjeiwhj w jtixtbdh kjeiwjzdhdmxbittgkbodxv mjme whj eimj</p> </blockquote> <p>This is what normally prints though</p> <blockquote> <p>xvkÈ bkikhxlrÈ wggbtfkjÈ wiylekgbdhxÈ wjjmÈ hkoÈ wigbtubxtÈ xvkÈ iwhjÈ uedjkmÈ glctbÈ gvrmdiwhjÈ iebbdielmeggtbxÈ ctbÈ xvtmkÈ gbtubxvkÈ wjjdxdthgbtubodllÈ khvxvkÈ imkbfdikÈ xtÈ xvkÈ bkudthÈ whjÈ gbtfdjkÈ hkoÈ tgxdthmÈ whjÈ tggtbxehdxdkmÈ ctbÈ mxejkhxmibdzdhtlturÈ whjÈ pemxdikÈ mxejdkmÈ mxdhÈ cokÈ wbkÈ wlmtÈ gbkgctbÈ ctebÈ hkoÈ zdhÈ cgvrmdikjeiwhjÈ qdhkmdtlturzzkjdydtivkzdmxbrwÈ zdhÈ zdjjlkkjeiwhjÈ wÈ jtixtbdhÈ kjeiwjzdhdmxbittgkbodxvÈ mjmeÈ whjÈ eimj</p> </blockquote> <p>or some variation of an odd character at the end of each word</p> <p>This is what the cryptogram array is filled with by the way</p> <blockquote> <p>wyijkcuvdpqlzhtgabmxefonrs</p> </blockquote> <p>Also this is the original message that gets encrypted</p> <p>The recently approved Academic Blueprint adds new academic programs to the campus and guides planning for physical and curricular support for those programs. The additional programs will enhance the campus service to the region and provide new options and opportunities for students. Criminology and justice studies starts in fall 2003. We are also preparing for four new majors in fall 2004 - physical education and kinesiology, mass media, biochemistry, a master’s in middle-level education and a doctorate in educational administration (in cooperation with SDSU and UCSD).</p> <p>P.S. Sorry about the weird formatting, just copied and pasted from the terminal, tried to fix it</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload