I am trying to learn about pointers and how to point to an array and how to increment a pointer
when i run this my output is: h,i,j,k,l,m
but i have no h,i,j,k,l,m in my code?!! this does not make sense to me
can anyone explain it?
Code:#include <stdio.h> #include <stdlib.h> #include <string.h> main() { char* ptr; int n; char string1 [] = { 'A' , 'B' , 'C' , 'D' , 'E' , 'F', 'G', '\0' } ; n = 3; ptr = string1; while ( *ptr != string1[6] ){ printf( "my pointer ptr points at: %c \n", ptr ); ptr++ ; } printf("%s",string1); getchar(); }



LinkBack URL
About LinkBacks


