If you run this code, you will see that the first two lists values do not show up.

I'm pretty sure this is because I am trying to print chars as numbers. I'm just wondering how to do this.

Thank you.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#define MAX 122
#define MIN 48


char GetRand();
void RC4(char *realpw, char *testpw, char increment, char temp, char CurrentChangingValue);
void Statistic_Analysis(int *statisticpw);

int main()
{
  unsigned char S1[256];
  unsigned char S2[256];
  char testpw[9][40]; 
  char realpw[9];
  char statisticpw[9][40];
  char increment;
  char CurrentChangingValue, r; 
  char temp;
  // used for cycling algorithm
  CurrentChangingValue, r = 0;
  temp = 20;

  for (r = 0; r <= 8; r++)
  {
	   realpw[r] = GetRand();  //generates a psuedo-random integers that serve as values for each password character
  }
  for (CurrentChangingValue = 0; CurrentChangingValue <= 9; CurrentChangingValue++)
  {
      increment = -20;
      if (increment <= 20 && increment != 0)
      {
          testpw[CurrentChangingValue][temp + increment] = (realpw[CurrentChangingValue] + increment);
          RC4(realpw, testpw, increment, temp, CurrentChangingValue);
         //statisticpw[CurrentChangingValue][temp + increment] = 
         increment = increment + 1;
      }
  }
 // Statistic_Analysis(statisticpw);
 system("PAUSE");
  return 0;
}

void RC4(char *realpw, char *testpw, char increment, char temp, char CurrentChangingValue)
{
	int positivecorrelations;
	unsigned char S1[256];
	unsigned char S2[256];
	char temp2;
	int i, j, j1, j2, t, N1, N2, w, l;
    i = positivecorrelations = 0;
    
	N1 = 11;   // testpw
	N2 = 11;   // realpw
	for(i = 0; i < 256; i++)
	{
		S1[i] = S2[i] = i;
	}
	j1 = j2 = i = 0;
	for(i = 0; i < 256; i++)
	{
		j1 = (j1 + S1[i] + realpw[i % N1]) & 0xFF;
		j2 = (j2 + S2[i] + testpw[i % N2]) & 0xFF;
		
		t = S1[i];
		S1[i] = S1[j1];
		S1[j1] = t;
		t = S2[i];
		S2[i] = S2[j2];
		S2[j2] = t;
	}
  // so that the correlations from pw are not added to those of the next and so on.
     i = 0;
     j = -5;
	for(i = 0; i < 256; i++)
	{    
         for (j = -5; j <= 5; j++)  //smear
         {
             if(S1[i] == S2[i + j])
             {
                      positivecorrelations = positivecorrelations + 1;
                      printf ("CurrentChangingValue: %c | number analyzed: %c | Amount Smeared: %d | positivecorrelations: %d \n", CurrentChangingValue, (increment - temp), j, positivecorrelations);  
             }
         }
    }
}

                      
/*			
       if (k%100 == 1) //temp
			{

			printf ("test positivecorrelations = %d \n", positivecorrelations); ///temp
			printf ("test statisticpw = %d \n ", statisticpw[k]); ///temp
            }                    
		   printf("*");
		else
		   printf("-");
		}
		return positivecorrelations;
     }
}
void Statistic_Analysis(int *statisticpw)
{
	int iterate, z, group, b;
    iterate, z, group, b = 0;
	int groupcorrelations[9];
    for (z = 0; z < 360 ; z++)
	{
		if (b != 40)
		{
		       groupcorrelations[group] = groupcorrelations[group] + statisticpw[z];
        }
		else
		{
			printf ("positive correlations = %d\n", groupcorrelations[group]);
			b = 0;
			group = group + 1;
		}
	}
 }
 
 */
 
char GetRand()
{
  static char Init = 0;
  char rc;
  if (Init == 0)
  {
    srand(time(NULL));
    Init = 1;
  }
  rc = (rand() % (MAX - MIN + 1) + MIN);
  return (rc);
}

>>I am trying to print chars as numbers. I'm just wondering how to do this.

Easy

char c = 'A';
printf("%d\n", c);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.