Forum Thread: Can Anyone Help Me with Tracing of This Program?

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

void cipher(int i, int c);
int findMin();
void makeArray(int, int);

char arr2222, darr2222, emessage111, retmessage111, key55;
char temp55, temp255;
int k = 0;

int main()
{
char message;

int i, j, klen, emlen, flag = 0;
int r, c, index, rows;

printf("Enter the key\n");
fflush(stdin);
gets(key);

printf("\nEnter message to be ciphered\n");
fflush(stdin);
gets(message);

strcpy(temp, key);
klen = strlen(key);

k = 0;
for (i = 0;; i++)
{
if (flag == 1)
break;

for (j = 0; keyj != NULL; j++)
{
if (messagek == NULL)
{
flag = 1;
arrij = '-';
}
else
{
arrij = messagek++;
}
}
}
r = i;
c = j;

for (i = 0; i < r; i++)
{
for (j = 0; j < c; j++)
{
printf("%c ", arrij);
}
printf("\n");
}

k = 0;

for (i = 0; i < klen; i++)
{
index = findMin();
cipher(index, r);
}

emessagek = '\0';
printf("\nEncrypted message is\n");
for (i = 0; emessagei != NULL; i++)
printf("%c", emessagei);

printf("\n\n");
//deciphering

emlen = strlen(emessage);
//emlen is length of encrypted message

strcpy(temp, key);

rows = emlen / klen;
//rows is no of row of the array to made from ciphered message

j = 0;

for (i = 0, k = 1; emessagei != NULL; i++, k++)
{
//printf("\nEmlen=%d",emlen);
temp2j++ = emessagei;
if ((k % rows) == 0)
{
temp2j = '\0';
index = findMin();
makeArray(index, rows);
j = 0;
}
}

printf("\nArray Retrieved is\n");

k = 0;
for (i = 0; i < r; i++)
{
for (j = 0; j < c; j++)
{
printf("%c ", darrij);
//retrieving message
retmessagek++ = darrij;

}
printf("\n");
}
retmessagek = '\0';

printf("\nMessage retrieved is\n");

for (i = 0; retmessagei != NULL; i++)
printf("%c", retmessagei);

return (0);
}

void cipher(int i, int r)
{
int j;
for (j = 0; j < r; j++)
{
{
emessagek++ = arrji;
}
}
// emessagek='\0';
}

void makeArray(int col, int row)
{
int i, j;

for (i = 0; i < row; i++)
{
darricol = temp2i;
}
}

int findMin()
{
int i, j, min, index;

min = temp0;
index = 0;
for (j = 0; tempj != NULL; j++)
{
if (tempj < min)
{
min = tempj;
index = j;
}
}

tempindex = 123;
return (index);
}

6 Responses

What the hell? fflush(stdin)? Who wrote this?

I Don't know buddy i just downloaded from random webpage

Put this in a pastebin please.

Sorry I'm Not Sure How That Works Frnd

Find a unique part of the code that stands out, paste into Google and find a Github page.

How Does That Help Please Explain?

Share Your Thoughts

  • Hot
  • Active