values not showing up in array
-
I'm writting code which fills up a character array with numeric values which will later be converted in to character values for use with an encryption function. The problem I'm having is that the array values do not seem to be making it into the array, and I'm pulling my hair out trying to figure what's going wrong. Source Code Follows
// make a 256 element alphanumeric string int nElementCount = 0; int nElementValue = 0; char szStringArray\[\] = "\\0"; // length check while ( nElementCount < 255 ) { szStringArray\[nElementCount\] = nElementValue; // post increment so that we go to the next // element number and value pair. nElementCount++; nElementValue++; } // debug message // // should list the entire range of elements in the array MessageBox(NULL, szStringArray, "Debug Message", MB\_OK);
As can see the code is pretty straight forward, but I just seem to not be able to get values into the array. It's probably something simple that I'm missing due to newbie-itis. If someone could point out what's wrong with my code and how to fix it, I'd appreciate it. It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
-
I'm writting code which fills up a character array with numeric values which will later be converted in to character values for use with an encryption function. The problem I'm having is that the array values do not seem to be making it into the array, and I'm pulling my hair out trying to figure what's going wrong. Source Code Follows
// make a 256 element alphanumeric string int nElementCount = 0; int nElementValue = 0; char szStringArray\[\] = "\\0"; // length check while ( nElementCount < 255 ) { szStringArray\[nElementCount\] = nElementValue; // post increment so that we go to the next // element number and value pair. nElementCount++; nElementValue++; } // debug message // // should list the entire range of elements in the array MessageBox(NULL, szStringArray, "Debug Message", MB\_OK);
As can see the code is pretty straight forward, but I just seem to not be able to get values into the array. It's probably something simple that I'm missing due to newbie-itis. If someone could point out what's wrong with my code and how to fix it, I'd appreciate it. It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
John Aldrich wrote: char szStringArray[] = "\0"; ?????!!!!!!!!!????????!!!!!!!!!! :wtf: :wtf: :wtf:
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
I'm writting code which fills up a character array with numeric values which will later be converted in to character values for use with an encryption function. The problem I'm having is that the array values do not seem to be making it into the array, and I'm pulling my hair out trying to figure what's going wrong. Source Code Follows
// make a 256 element alphanumeric string int nElementCount = 0; int nElementValue = 0; char szStringArray\[\] = "\\0"; // length check while ( nElementCount < 255 ) { szStringArray\[nElementCount\] = nElementValue; // post increment so that we go to the next // element number and value pair. nElementCount++; nElementValue++; } // debug message // // should list the entire range of elements in the array MessageBox(NULL, szStringArray, "Debug Message", MB\_OK);
As can see the code is pretty straight forward, but I just seem to not be able to get values into the array. It's probably something simple that I'm missing due to newbie-itis. If someone could point out what's wrong with my code and how to fix it, I'd appreciate it. It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
Sorry for the prev reply, but I just watched ugggh Event Horizon on TV [roughly 40% of the latter 60%] and am still not fully normal yet :-( John Aldrich wrote: char szStringArray[] = "\0"; Change that to :- char szStringArray[256] ; Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
Sorry for the prev reply, but I just watched ugggh Event Horizon on TV [roughly 40% of the latter 60%] and am still not fully normal yet :-( John Aldrich wrote: char szStringArray[] = "\0"; Change that to :- char szStringArray[256] ; Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
Just made that change. My dubug statement is still showing no values in the array. is there another check I can do to see if there actually are values? It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
-
Just made that change. My dubug statement is still showing no values in the array. is there another check I can do to see if there actually are values? It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
John Aldrich wrote: Just made that change. My dubug statement is still showing no values in the array. is there another check I can do to see if there actually are values? That's because nElementValue is initially 0 and you assign it as the first value of your array. Strings are 0-terminated. Thus your MessageBox won't come up because it sees a null string. Start with nElementValue = 32. 32 is space and 32 upwards is legal characters and stop at 127. otherwise you have all kinds of funny control chasracters which might end up as boxes in the text on screen or might have other bad side effects. Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]