This produces the incorrect output.
Can someone tell me what I am doing wrong. The first 1,2 or 3 characters are displayed (depending on the chars) but the rest are random.
Note: This is just a learning exercise & am aware there are easier ways to do this.
int main(int argc, char *argv[])
{
//Assume 1 arg only
int len = strlen(argv[1]);
char *d = malloc (strlen(argv[1])+1);
strcpy(d,argv[1]);
char *x;
x = &d[0];
int j,k;
j = sizeof(char*);
for (k=0;k<len;k++){
printf("Value: %c\n\n", (*x + (k*j)));
}