
Originally Posted by
Salem
Post a complete code we can copy/paste/run to see what you're seeing.
Object is to change an inputted string characters as per the massaged values of the random number
I want to use the ist byte of hex value eg. FA in hex value FFFFFFFA
and add that to the value of the character in the input string
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char string1[30], string2[30], myHexBuf[50],j;
int i, length, bufsize, myBuf, myDivMod, myDivAdd, myDivStrlen;
unsigned int myRand; //myHexBuf; //, myRand;
printf("Enter String\n");
scanf("%s",string1);
length = strlen(string1);
bufsize = length * 4;
myBuf = (malloc(bufsize)); // allocate buffer size of strlen chars
string * 4 for the hex values
srand(length); // seed rand generator
for (i = 0; i < length; ++i) {
myRand = rand(); // get random number
myDivMod = myRand % length; // - length / 2; // get mod of random number
myRand = myRand / length; // should equal 6 with 4D random
myRand = myRand * -1; // negate mRand by * -1
myRand = myRand + myDivMod;
//j = string1[i];
//j += myRand;
//string2[i] = j;
}
return 0;
}