Increment pointer to enumerate char[ ]
pThis produces the incorrect output. /p pCan 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. /p pstrongNote/strong: emThis is just a
learning exercise amp; am aware there are easier ways to do this./em/p
precodeint 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 = amp;d[0]; int j,k; j = sizeof(char*); for (k=0;klt;len;k++){
printf(Value: %c\n\n, (*x + (k*j))); } /code/pre
No comments:
Post a Comment