Results 1 to 3 of 3
hi, please can anyone solve my doubt.
#include <stdio.h>
#include <stdio.h>
main()
{
char names[2][10] =
{
"ABCDEF",
"GHIJKL"
};
char **ptr;
ptr = names;
printf("%s\n", ptr+1);
}
For this ...
- 05-26-2010 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 85
Tell me this stuff with Pointers
hi, please can anyone solve my doubt.
#include <stdio.h>
#include <stdio.h>
main()
{
char names[2][10] =
{
"ABCDEF",
"GHIJKL"
};
char **ptr;
ptr = names;
printf("%s\n", ptr+1);
}
For this program, I expected that output should be GHIJKL, But the output is EF.
and if I change the ptr+1 to ptr[1], then there is a seqfault, what does this mean.
Thanks in advance.
Mahesh Gupta.B
- 05-27-2010 #2
If i'm not wrong - i think it should char* .
#include <stdio.h>
main()
{
char names[2][10] =
{
"ABCDEF",
"GHIJKL"
};
char *ptr;
ptr = names;
printf("%s\n",ptr);
printf("%s\n", ptr + 10);
}
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 05-30-2010 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
This really looks like school work. Remember that it is not allowed to ask for help solving classwork in the forums!
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


